| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
# Copyright: (c) 2018, Ansible Project |
| 4 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
import copy |
| 7 |
from typing import Optional |
| 8 |
|
| 9 |
try: |
| 10 |
import botocore.exceptions as exception_waiter |
| 11 |
import botocore.waiter as core_waiter |
| 12 |
except ImportError: |
| 13 |
pass # caught by HAS_BOTO3 |
| 14 |
|
| 15 |
from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule |
| 16 |
from ansible_collections.amazon.aws.plugins.module_utils.retries import RetryingBotoClientWrapper |
| 17 |
|
| 18 |
ec2_data = { |
| 19 |
"version": 2, |
| 20 |
"waiters": { |
| 21 |
"ImageAvailable": { |
| 22 |
"operation": "DescribeImages", |
| 23 |
"maxAttempts": 80, |
| 24 |
"delay": 15, |
| 25 |
"acceptors": [ |
| 26 |
{"state": "success", "matcher": "pathAll", "argument": "Images[].State", "expected": "available"}, |
| 27 |
{"matcher": "error", "expected": "InvalidAMIID.NotFound", "state": "retry"}, |
| 28 |
{"state": "failure", "matcher": "pathAny", "argument": "Images[].State", "expected": "failed"}, |
| 29 |
], |
| 30 |
}, |
| 31 |
"InternetGatewayExists": { |
| 32 |
"delay": 5, |
| 33 |
"maxAttempts": 40, |
| 34 |
"operation": "DescribeInternetGateways", |
| 35 |
"acceptors": [ |
| 36 |
{"matcher": "path", "expected": True, "argument": "length(InternetGateways) > `0`", "state": "success"}, |
| 37 |
{"matcher": "error", "expected": "InvalidInternetGatewayID.NotFound", "state": "retry"}, |
| 38 |
], |
| 39 |
}, |
| 40 |
"InternetGatewayAttached": { |
| 41 |
"operation": "DescribeInternetGateways", |
| 42 |
"delay": 5, |
| 43 |
"maxAttempts": 40, |
| 44 |
"acceptors": [ |
| 45 |
{ |
| 46 |
"expected": "available", |
| 47 |
"matcher": "pathAll", |
| 48 |
"state": "success", |
| 49 |
"argument": "InternetGateways[].Attachments[].State", |
| 50 |
}, |
| 51 |
{"matcher": "error", "expected": "InvalidInternetGatewayID.NotFound", "state": "retry"}, |
| 52 |
], |
| 53 |
}, |
| 54 |
"TransitGatewayAvailable": { |
| 55 |
"operation": "DescribeTransitGateways", |
| 56 |
"delay": 5, |
| 57 |
"maxAttempts": 120, |
| 58 |
"acceptors": [ |
| 59 |
{ |
| 60 |
"state": "success", |
| 61 |
"matcher": "pathAll", |
| 62 |
"argument": "TransitGateways[].State", |
| 63 |
"expected": "available", |
| 64 |
}, |
| 65 |
{ |
| 66 |
"state": "retry", |
| 67 |
"matcher": "pathAll", |
| 68 |
"argument": "TransitGateways[].State", |
| 69 |
"expected": "pending", |
| 70 |
}, |
| 71 |
{ |
| 72 |
"state": "failure", |
| 73 |
"matcher": "pathAny", |
| 74 |
"argument": "TransitGateways[].State", |
| 75 |
"expected": "failed", |
| 76 |
}, |
| 77 |
], |
| 78 |
}, |
| 79 |
"TransitGatewayDeleted": { |
| 80 |
"operation": "DescribeTransitGateways", |
| 81 |
"delay": 5, |
| 82 |
"maxAttempts": 120, |
| 83 |
"acceptors": [ |
| 84 |
{ |
| 85 |
"state": "success", |
| 86 |
"matcher": "pathAll", |
| 87 |
"argument": "TransitGateways[].State", |
| 88 |
"expected": "deleted", |
| 89 |
}, |
| 90 |
{ |
| 91 |
"state": "retry", |
| 92 |
"matcher": "pathAll", |
| 93 |
"argument": "TransitGateways[].State", |
| 94 |
"expected": "deleting", |
| 95 |
}, |
| 96 |
{ |
| 97 |
"state": "failure", |
| 98 |
"matcher": "pathAny", |
| 99 |
"argument": "TransitGateways[].State", |
| 100 |
"expected": "failed", |
| 101 |
}, |
| 102 |
], |
| 103 |
}, |
| 104 |
"TGWVpcAttachmentAvailable": { |
| 105 |
"operation": "DescribeTransitGatewayVpcAttachments", |
| 106 |
"delay": 5, |
| 107 |
"maxAttempts": 120, |
| 108 |
"acceptors": [ |
| 109 |
{ |
| 110 |
"expected": "available", |
| 111 |
"matcher": "pathAll", |
| 112 |
"state": "success", |
| 113 |
"argument": "TransitGatewayVpcAttachments[].State", |
| 114 |
}, |
| 115 |
{ |
| 116 |
"state": "retry", |
| 117 |
"matcher": "pathAny", |
| 118 |
"argument": "TransitGatewayVpcAttachments[].State", |
| 119 |
"expected": "pending", |
| 120 |
}, |
| 121 |
{"matcher": "error", "expected": "InvalidRouteTableID.NotFound", "state": "retry"}, |
| 122 |
], |
| 123 |
}, |
| 124 |
"TGWVpcAttachmentDeleted": { |
| 125 |
"operation": "DescribeTransitGatewayVpcAttachments", |
| 126 |
"delay": 5, |
| 127 |
"maxAttempts": 120, |
| 128 |
"acceptors": [ |
| 129 |
{ |
| 130 |
"state": "retry", |
| 131 |
"matcher": "pathAll", |
| 132 |
"argument": "TransitGatewayVpcAttachments[].State", |
| 133 |
"expected": "deleting", |
| 134 |
}, |
| 135 |
{ |
| 136 |
"state": "success", |
| 137 |
"expected": "deleted", |
| 138 |
"matcher": "pathAll", |
| 139 |
"argument": "TransitGatewayVpcAttachments[].State", |
| 140 |
}, |
| 141 |
{ |
| 142 |
"expected": True, |
| 143 |
"matcher": "path", |
| 144 |
"state": "success", |
| 145 |
"argument": "length(TransitGatewayVpcAttachments[]) == `0`", |
| 146 |
}, |
| 147 |
{"matcher": "error", "expected": "InvalidRouteTableID.NotFound", "state": "retry"}, |
| 148 |
], |
| 149 |
}, |
| 150 |
"NetworkInterfaceAttached": { |
| 151 |
"operation": "DescribeNetworkInterfaces", |
| 152 |
"delay": 5, |
| 153 |
"maxAttempts": 40, |
| 154 |
"acceptors": [ |
| 155 |
{ |
| 156 |
"expected": "attached", |
| 157 |
"matcher": "pathAll", |
| 158 |
"state": "success", |
| 159 |
"argument": "NetworkInterfaces[].Attachment.Status", |
| 160 |
}, |
| 161 |
{"expected": "InvalidNetworkInterfaceID.NotFound", "matcher": "error", "state": "failure"}, |
| 162 |
], |
| 163 |
}, |
| 164 |
"NetworkInterfaceAvailable": { |
| 165 |
"operation": "DescribeNetworkInterfaces", |
| 166 |
"delay": 5, |
| 167 |
"maxAttempts": 40, |
| 168 |
"acceptors": [ |
| 169 |
{ |
| 170 |
"expected": "available", |
| 171 |
"matcher": "pathAll", |
| 172 |
"state": "success", |
| 173 |
"argument": "NetworkInterfaces[].Status", |
| 174 |
}, |
| 175 |
{"expected": "InvalidNetworkInterfaceID.NotFound", "matcher": "error", "state": "retry"}, |
| 176 |
], |
| 177 |
}, |
| 178 |
"NetworkInterfaceDeleted": { |
| 179 |
"operation": "DescribeNetworkInterfaces", |
| 180 |
"delay": 5, |
| 181 |
"maxAttempts": 40, |
| 182 |
"acceptors": [ |
| 183 |
{ |
| 184 |
"matcher": "path", |
| 185 |
"expected": True, |
| 186 |
"argument": "length(NetworkInterfaces[]) > `0`", |
| 187 |
"state": "retry", |
| 188 |
}, |
| 189 |
{ |
| 190 |
"matcher": "path", |
| 191 |
"expected": True, |
| 192 |
"argument": "length(NetworkInterfaces[]) == `0`", |
| 193 |
"state": "success", |
| 194 |
}, |
| 195 |
{"expected": "InvalidNetworkInterfaceID.NotFound", "matcher": "error", "state": "success"}, |
| 196 |
], |
| 197 |
}, |
| 198 |
"NetworkInterfaceDeleteOnTerminate": { |
| 199 |
"operation": "DescribeNetworkInterfaces", |
| 200 |
"delay": 5, |
| 201 |
"maxAttempts": 10, |
| 202 |
"acceptors": [ |
| 203 |
{ |
| 204 |
"expected": True, |
| 205 |
"matcher": "pathAll", |
| 206 |
"state": "success", |
| 207 |
"argument": "NetworkInterfaces[].Attachment.DeleteOnTermination", |
| 208 |
}, |
| 209 |
{"expected": "InvalidNetworkInterfaceID.NotFound", "matcher": "error", "state": "failure"}, |
| 210 |
], |
| 211 |
}, |
| 212 |
"NetworkInterfaceNoDeleteOnTerminate": { |
| 213 |
"operation": "DescribeNetworkInterfaces", |
| 214 |
"delay": 5, |
| 215 |
"maxAttempts": 10, |
| 216 |
"acceptors": [ |
| 217 |
{ |
| 218 |
"expected": False, |
| 219 |
"matcher": "pathAll", |
| 220 |
"state": "success", |
| 221 |
"argument": "NetworkInterfaces[].Attachment.DeleteOnTermination", |
| 222 |
}, |
| 223 |
{"expected": "InvalidNetworkInterfaceID.NotFound", "matcher": "error", "state": "failure"}, |
| 224 |
], |
| 225 |
}, |
| 226 |
"RouteTableExists": { |
| 227 |
"delay": 5, |
| 228 |
"maxAttempts": 40, |
| 229 |
"operation": "DescribeRouteTables", |
| 230 |
"acceptors": [ |
| 231 |
{"matcher": "path", "expected": True, "argument": "length(RouteTables[]) > `0`", "state": "success"}, |
| 232 |
{"matcher": "error", "expected": "InvalidRouteTableID.NotFound", "state": "retry"}, |
| 233 |
], |
| 234 |
}, |
| 235 |
"SecurityGroupExists": { |
| 236 |
"delay": 5, |
| 237 |
"maxAttempts": 40, |
| 238 |
"operation": "DescribeSecurityGroups", |
| 239 |
"acceptors": [ |
| 240 |
{"matcher": "path", "expected": True, "argument": "length(SecurityGroups[]) > `0`", "state": "success"}, |
| 241 |
{"matcher": "error", "expected": "InvalidGroup.NotFound", "state": "retry"}, |
| 242 |
], |
| 243 |
}, |
| 244 |
"SnapshotCompleted": { |
| 245 |
"delay": 15, |
| 246 |
"operation": "DescribeSnapshots", |
| 247 |
"maxAttempts": 40, |
| 248 |
"acceptors": [ |
| 249 |
{"expected": "completed", "matcher": "pathAll", "state": "success", "argument": "Snapshots[].State"} |
| 250 |
], |
| 251 |
}, |
| 252 |
"SubnetAvailable": { |
| 253 |
"delay": 15, |
| 254 |
"operation": "DescribeSubnets", |
| 255 |
"maxAttempts": 40, |
| 256 |
"acceptors": [ |
| 257 |
{"expected": "available", "matcher": "pathAll", "state": "success", "argument": "Subnets[].State"} |
| 258 |
], |
| 259 |
}, |
| 260 |
"SubnetExists": { |
| 261 |
"delay": 5, |
| 262 |
"maxAttempts": 40, |
| 263 |
"operation": "DescribeSubnets", |
| 264 |
"acceptors": [ |
| 265 |
{"matcher": "path", "expected": True, "argument": "length(Subnets[]) > `0`", "state": "success"}, |
| 266 |
{"matcher": "error", "expected": "InvalidSubnetID.NotFound", "state": "retry"}, |
| 267 |
], |
| 268 |
}, |
| 269 |
"SubnetHasMapPublic": { |
| 270 |
"delay": 5, |
| 271 |
"maxAttempts": 40, |
| 272 |
"operation": "DescribeSubnets", |
| 273 |
"acceptors": [ |
| 274 |
{ |
| 275 |
"matcher": "pathAll", |
| 276 |
"expected": True, |
| 277 |
"argument": "Subnets[].MapPublicIpOnLaunch", |
| 278 |
"state": "success", |
| 279 |
}, |
| 280 |
], |
| 281 |
}, |
| 282 |
"SubnetNoMapPublic": { |
| 283 |
"delay": 5, |
| 284 |
"maxAttempts": 40, |
| 285 |
"operation": "DescribeSubnets", |
| 286 |
"acceptors": [ |
| 287 |
{ |
| 288 |
"matcher": "pathAll", |
| 289 |
"expected": False, |
| 290 |
"argument": "Subnets[].MapPublicIpOnLaunch", |
| 291 |
"state": "success", |
| 292 |
}, |
| 293 |
], |
| 294 |
}, |
| 295 |
"SubnetHasAssignIpv6": { |
| 296 |
"delay": 5, |
| 297 |
"maxAttempts": 40, |
| 298 |
"operation": "DescribeSubnets", |
| 299 |
"acceptors": [ |
| 300 |
{ |
| 301 |
"matcher": "pathAll", |
| 302 |
"expected": True, |
| 303 |
"argument": "Subnets[].AssignIpv6AddressOnCreation", |
| 304 |
"state": "success", |
| 305 |
}, |
| 306 |
], |
| 307 |
}, |
| 308 |
"SubnetNoAssignIpv6": { |
| 309 |
"delay": 5, |
| 310 |
"maxAttempts": 40, |
| 311 |
"operation": "DescribeSubnets", |
| 312 |
"acceptors": [ |
| 313 |
{ |
| 314 |
"matcher": "pathAll", |
| 315 |
"expected": False, |
| 316 |
"argument": "Subnets[].AssignIpv6AddressOnCreation", |
| 317 |
"state": "success", |
| 318 |
}, |
| 319 |
], |
| 320 |
}, |
| 321 |
"SubnetDeleted": { |
| 322 |
"delay": 5, |
| 323 |
"maxAttempts": 40, |
| 324 |
"operation": "DescribeSubnets", |
| 325 |
"acceptors": [ |
| 326 |
{"matcher": "path", "expected": True, "argument": "length(Subnets[]) > `0`", "state": "retry"}, |
| 327 |
{"matcher": "error", "expected": "InvalidSubnetID.NotFound", "state": "success"}, |
| 328 |
], |
| 329 |
}, |
| 330 |
"VpcAvailable": { |
| 331 |
"delay": 15, |
| 332 |
"operation": "DescribeVpcs", |
| 333 |
"maxAttempts": 40, |
| 334 |
"acceptors": [ |
| 335 |
{"expected": "available", "matcher": "pathAll", "state": "success", "argument": "Vpcs[].State"} |
| 336 |
], |
| 337 |
}, |
| 338 |
"VpcExists": { |
| 339 |
"operation": "DescribeVpcs", |
| 340 |
"delay": 1, |
| 341 |
"maxAttempts": 5, |
| 342 |
"acceptors": [ |
| 343 |
{"matcher": "status", "expected": 200, "state": "success"}, |
| 344 |
{"matcher": "error", "expected": "InvalidVpcID.NotFound", "state": "retry"}, |
| 345 |
], |
| 346 |
}, |
| 347 |
"VpcEndpointExists": { |
| 348 |
"delay": 5, |
| 349 |
"maxAttempts": 40, |
| 350 |
"operation": "DescribeVpcEndpoints", |
| 351 |
"acceptors": [ |
| 352 |
{"matcher": "path", "expected": True, "argument": "length(VpcEndpoints[]) > `0`", "state": "success"}, |
| 353 |
{"matcher": "error", "expected": "InvalidVpcEndpointId.NotFound", "state": "retry"}, |
| 354 |
], |
| 355 |
}, |
| 356 |
"VpnGatewayExists": { |
| 357 |
"delay": 5, |
| 358 |
"maxAttempts": 40, |
| 359 |
"operation": "DescribeVpnGateways", |
| 360 |
"acceptors": [ |
| 361 |
{"matcher": "path", "expected": True, "argument": "length(VpnGateways[]) > `0`", "state": "success"}, |
| 362 |
{"matcher": "error", "expected": "InvalidVpnGatewayID.NotFound", "state": "retry"}, |
| 363 |
], |
| 364 |
}, |
| 365 |
"VpnGatewayDetached": { |
| 366 |
"delay": 5, |
| 367 |
"maxAttempts": 40, |
| 368 |
"operation": "DescribeVpnGateways", |
| 369 |
"acceptors": [ |
| 370 |
{ |
| 371 |
"expected": "detached", |
| 372 |
"matcher": "pathAll", |
| 373 |
"state": "success", |
| 374 |
"argument": "VpnGateways[].VpcAttachments[].State", |
| 375 |
}, |
| 376 |
], |
| 377 |
}, |
| 378 |
"VpnGatewayAttached": { |
| 379 |
"delay": 5, |
| 380 |
"maxAttempts": 40, |
| 381 |
"operation": "DescribeVpnGateways", |
| 382 |
"acceptors": [ |
| 383 |
{ |
| 384 |
"expected": "attached", |
| 385 |
"matcher": "pathAll", |
| 386 |
"state": "success", |
| 387 |
"argument": "VpnGateways[].VpcAttachments[].State", |
| 388 |
}, |
| 389 |
], |
| 390 |
}, |
| 391 |
"NatGatewayDeleted": { |
| 392 |
"delay": 5, |
| 393 |
"maxAttempts": 40, |
| 394 |
"operation": "DescribeNatGateways", |
| 395 |
"acceptors": [ |
| 396 |
{"state": "success", "matcher": "pathAll", "expected": "deleted", "argument": "NatGateways[].State"}, |
| 397 |
{"state": "success", "matcher": "error", "expected": "NatGatewayNotFound"}, |
| 398 |
], |
| 399 |
}, |
| 400 |
"NatGatewayAvailable": { |
| 401 |
"delay": 5, |
| 402 |
"maxAttempts": 40, |
| 403 |
"operation": "DescribeNatGateways", |
| 404 |
"acceptors": [ |
| 405 |
{"state": "success", "matcher": "pathAll", "expected": "available", "argument": "NatGateways[].State"}, |
| 406 |
{"state": "retry", "matcher": "error", "expected": "NatGatewayNotFound"}, |
| 407 |
], |
| 408 |
}, |
| 409 |
"VolumeAvailable": { |
| 410 |
"delay": 15, |
| 411 |
"maxAttempts": 40, |
| 412 |
"operation": "DescribeVolumes", |
| 413 |
"acceptors": [ |
| 414 |
{"state": "success", "matcher": "pathAll", "expected": "available", "argument": "Volumes[].State"}, |
| 415 |
{"state": "failure", "matcher": "pathAny", "argument": "Volumes[].State", "expected": "deleted"}, |
| 416 |
], |
| 417 |
}, |
| 418 |
"VolumeDeleted": { |
| 419 |
"delay": 15, |
| 420 |
"maxAttempts": 40, |
| 421 |
"operation": "DescribeVolumes", |
| 422 |
"acceptors": [ |
| 423 |
{"state": "success", "matcher": "pathAll", "expected": "deleted", "argument": "Volumes[].State"}, |
| 424 |
{"state": "success", "matcher": "error", "expected": "InvalidVolume.NotFound"}, |
| 425 |
], |
| 426 |
}, |
| 427 |
"VolumeInUse": { |
| 428 |
"delay": 15, |
| 429 |
"maxAttempts": 40, |
| 430 |
"operation": "DescribeVolumes", |
| 431 |
"acceptors": [ |
| 432 |
{"state": "success", "matcher": "pathAll", "expected": "in-use", "argument": "Volumes[].State"}, |
| 433 |
{"state": "failure", "matcher": "pathAny", "argument": "Volumes[].State", "expected": "deleted"}, |
| 434 |
], |
| 435 |
}, |
| 436 |
}, |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
waf_data = { |
| 441 |
"version": 2, |
| 442 |
"waiters": { |
| 443 |
"ChangeTokenInSync": { |
| 444 |
"delay": 20, |
| 445 |
"maxAttempts": 60, |
| 446 |
"operation": "GetChangeTokenStatus", |
| 447 |
"acceptors": [ |
| 448 |
{"matcher": "path", "expected": True, "argument": "ChangeTokenStatus == 'INSYNC'", "state": "success"}, |
| 449 |
{"matcher": "error", "expected": "WAFInternalErrorException", "state": "retry"}, |
| 450 |
], |
| 451 |
} |
| 452 |
}, |
| 453 |
} |
| 454 |
|
| 455 |
eks_data = { |
| 456 |
"version": 2, |
| 457 |
"waiters": { |
| 458 |
"ClusterActive": { |
| 459 |
"delay": 20, |
| 460 |
"maxAttempts": 60, |
| 461 |
"operation": "DescribeCluster", |
| 462 |
"acceptors": [ |
| 463 |
{"state": "success", "matcher": "path", "argument": "cluster.status", "expected": "ACTIVE"}, |
| 464 |
{"state": "retry", "matcher": "error", "expected": "ResourceNotFoundException"}, |
| 465 |
], |
| 466 |
}, |
| 467 |
"ClusterDeleted": { |
| 468 |
"delay": 20, |
| 469 |
"maxAttempts": 60, |
| 470 |
"operation": "DescribeCluster", |
| 471 |
"acceptors": [ |
| 472 |
{"state": "retry", "matcher": "path", "argument": "cluster.status != 'DELETED'", "expected": True}, |
| 473 |
{"state": "success", "matcher": "error", "expected": "ResourceNotFoundException"}, |
| 474 |
], |
| 475 |
}, |
| 476 |
"FargateProfileActive": { |
| 477 |
"delay": 20, |
| 478 |
"maxAttempts": 30, |
| 479 |
"operation": "DescribeFargateProfile", |
| 480 |
"acceptors": [ |
| 481 |
{"state": "success", "matcher": "path", "argument": "fargateProfile.status", "expected": "ACTIVE"}, |
| 482 |
{"state": "retry", "matcher": "error", "expected": "ResourceNotFoundException"}, |
| 483 |
], |
| 484 |
}, |
| 485 |
"FargateProfileDeleted": { |
| 486 |
"delay": 20, |
| 487 |
"maxAttempts": 30, |
| 488 |
"operation": "DescribeFargateProfile", |
| 489 |
"acceptors": [ |
| 490 |
{ |
| 491 |
"state": "retry", |
| 492 |
"matcher": "path", |
| 493 |
"argument": "fargateProfile.status == 'DELETING'", |
| 494 |
"expected": True, |
| 495 |
}, |
| 496 |
{"state": "success", "matcher": "error", "expected": "ResourceNotFoundException"}, |
| 497 |
], |
| 498 |
}, |
| 499 |
"NodegroupActive": { |
| 500 |
"delay": 20, |
| 501 |
"maxAttempts": 60, |
| 502 |
"operation": "DescribeNodegroup", |
| 503 |
"acceptors": [ |
| 504 |
{"state": "success", "matcher": "path", "argument": "nodegroup.status", "expected": "ACTIVE"}, |
| 505 |
{"state": "retry", "matcher": "error", "expected": "ResourceNotFoundException"}, |
| 506 |
], |
| 507 |
}, |
| 508 |
"NodegroupDeleted": { |
| 509 |
"delay": 20, |
| 510 |
"maxAttempts": 60, |
| 511 |
"operation": "DescribeNodegroup", |
| 512 |
"acceptors": [ |
| 513 |
{"state": "retry", "matcher": "path", "argument": "nodegroup.status == 'DELETING'", "expected": True}, |
| 514 |
{"state": "success", "matcher": "error", "expected": "ResourceNotFoundException"}, |
| 515 |
], |
| 516 |
}, |
| 517 |
}, |
| 518 |
} |
| 519 |
|
| 520 |
|
| 521 |
elb_data = { |
| 522 |
"version": 2, |
| 523 |
"waiters": { |
| 524 |
"AnyInstanceInService": { |
| 525 |
"acceptors": [ |
| 526 |
{ |
| 527 |
"argument": "InstanceStates[].State", |
| 528 |
"expected": "InService", |
| 529 |
"matcher": "pathAny", |
| 530 |
"state": "success", |
| 531 |
} |
| 532 |
], |
| 533 |
"delay": 15, |
| 534 |
"maxAttempts": 40, |
| 535 |
"operation": "DescribeInstanceHealth", |
| 536 |
}, |
| 537 |
"InstanceDeregistered": { |
| 538 |
"delay": 15, |
| 539 |
"operation": "DescribeInstanceHealth", |
| 540 |
"maxAttempts": 40, |
| 541 |
"acceptors": [ |
| 542 |
{ |
| 543 |
"expected": "OutOfService", |
| 544 |
"matcher": "pathAll", |
| 545 |
"state": "success", |
| 546 |
"argument": "InstanceStates[].State", |
| 547 |
}, |
| 548 |
{"matcher": "error", "expected": "InvalidInstance", "state": "success"}, |
| 549 |
], |
| 550 |
}, |
| 551 |
"InstanceInService": { |
| 552 |
"acceptors": [ |
| 553 |
{ |
| 554 |
"argument": "InstanceStates[].State", |
| 555 |
"expected": "InService", |
| 556 |
"matcher": "pathAll", |
| 557 |
"state": "success", |
| 558 |
}, |
| 559 |
{"matcher": "error", "expected": "InvalidInstance", "state": "retry"}, |
| 560 |
], |
| 561 |
"delay": 15, |
| 562 |
"maxAttempts": 40, |
| 563 |
"operation": "DescribeInstanceHealth", |
| 564 |
}, |
| 565 |
"LoadBalancerCreated": { |
| 566 |
"delay": 10, |
| 567 |
"maxAttempts": 60, |
| 568 |
"operation": "DescribeLoadBalancers", |
| 569 |
"acceptors": [ |
| 570 |
{ |
| 571 |
"matcher": "path", |
| 572 |
"expected": True, |
| 573 |
"argument": "length(LoadBalancerDescriptions[]) > `0`", |
| 574 |
"state": "success", |
| 575 |
}, |
| 576 |
{ |
| 577 |
"matcher": "error", |
| 578 |
"expected": "LoadBalancerNotFound", |
| 579 |
"state": "retry", |
| 580 |
}, |
| 581 |
], |
| 582 |
}, |
| 583 |
"LoadBalancerDeleted": { |
| 584 |
"delay": 10, |
| 585 |
"maxAttempts": 60, |
| 586 |
"operation": "DescribeLoadBalancers", |
| 587 |
"acceptors": [ |
| 588 |
{ |
| 589 |
"matcher": "path", |
| 590 |
"expected": True, |
| 591 |
"argument": "length(LoadBalancerDescriptions[]) > `0`", |
| 592 |
"state": "retry", |
| 593 |
}, |
| 594 |
{ |
| 595 |
"matcher": "error", |
| 596 |
"expected": "LoadBalancerNotFound", |
| 597 |
"state": "success", |
| 598 |
}, |
| 599 |
], |
| 600 |
}, |
| 601 |
}, |
| 602 |
} |
| 603 |
|
| 604 |
elbv2_data = { |
| 605 |
"version": 2, |
| 606 |
"waiters": { |
| 607 |
"LoadBalancerAvailable": { |
| 608 |
"delay": 15, |
| 609 |
"operation": "DescribeLoadBalancers", |
| 610 |
"maxAttempts": 40, |
| 611 |
"acceptors": [ |
| 612 |
{ |
| 613 |
"state": "success", |
| 614 |
"matcher": "pathAll", |
| 615 |
"argument": "LoadBalancers[].State.Code", |
| 616 |
"expected": "active", |
| 617 |
}, |
| 618 |
{ |
| 619 |
"state": "retry", |
| 620 |
"matcher": "pathAny", |
| 621 |
"argument": "LoadBalancers[].State.Code", |
| 622 |
"expected": "provisioning", |
| 623 |
}, |
| 624 |
{"state": "retry", "matcher": "error", "expected": "LoadBalancerNotFound"}, |
| 625 |
], |
| 626 |
}, |
| 627 |
"LoadBalancerIpAddressTypeIpv4": { |
| 628 |
"delay": 15, |
| 629 |
"operation": "DescribeLoadBalancers", |
| 630 |
"maxAttempts": 40, |
| 631 |
"acceptors": [ |
| 632 |
{ |
| 633 |
"state": "success", |
| 634 |
"matcher": "pathAll", |
| 635 |
"argument": "LoadBalancers[].IpAddressType", |
| 636 |
"expected": "ipv4", |
| 637 |
}, |
| 638 |
{ |
| 639 |
"state": "retry", |
| 640 |
"matcher": "pathAny", |
| 641 |
"argument": "LoadBalancers[].IpAddressType", |
| 642 |
"expected": "dualstack", |
| 643 |
}, |
| 644 |
{"state": "failure", "matcher": "error", "expected": "LoadBalancerNotFound"}, |
| 645 |
], |
| 646 |
}, |
| 647 |
"LoadBalancerIpAddressTypeDualStack": { |
| 648 |
"delay": 15, |
| 649 |
"operation": "DescribeLoadBalancers", |
| 650 |
"maxAttempts": 40, |
| 651 |
"acceptors": [ |
| 652 |
{ |
| 653 |
"state": "success", |
| 654 |
"matcher": "pathAll", |
| 655 |
"argument": "LoadBalancers[].IpAddressType", |
| 656 |
"expected": "dualstack", |
| 657 |
}, |
| 658 |
{ |
| 659 |
"state": "retry", |
| 660 |
"matcher": "pathAny", |
| 661 |
"argument": "LoadBalancers[].IpAddressType", |
| 662 |
"expected": "ipv4", |
| 663 |
}, |
| 664 |
{"state": "failure", "matcher": "error", "expected": "LoadBalancerNotFound"}, |
| 665 |
], |
| 666 |
}, |
| 667 |
"LoadBalancersDeleted": { |
| 668 |
"delay": 15, |
| 669 |
"operation": "DescribeLoadBalancers", |
| 670 |
"maxAttempts": 40, |
| 671 |
"acceptors": [ |
| 672 |
{ |
| 673 |
"state": "retry", |
| 674 |
"matcher": "pathAll", |
| 675 |
"argument": "LoadBalancers[].State.Code", |
| 676 |
"expected": "active", |
| 677 |
}, |
| 678 |
{"matcher": "error", "expected": "LoadBalancerNotFound", "state": "success"}, |
| 679 |
], |
| 680 |
}, |
| 681 |
}, |
| 682 |
} |
| 683 |
|
| 684 |
|
| 685 |
rds_data = { |
| 686 |
"version": 2, |
| 687 |
"waiters": { |
| 688 |
"DBClusterPromoting": { |
| 689 |
"delay": 5, |
| 690 |
"maxAttempts": 60, |
| 691 |
"operation": "DescribeDBClusters", |
| 692 |
"acceptors": [ |
| 693 |
{ |
| 694 |
"state": "success", |
| 695 |
"matcher": "pathAll", |
| 696 |
"argument": "DBClusters[].Status", |
| 697 |
"expected": "promoting", |
| 698 |
}, |
| 699 |
], |
| 700 |
}, |
| 701 |
"DBInstanceStopped": { |
| 702 |
"delay": 20, |
| 703 |
"maxAttempts": 60, |
| 704 |
"operation": "DescribeDBInstances", |
| 705 |
"acceptors": [ |
| 706 |
{ |
| 707 |
"state": "success", |
| 708 |
"matcher": "pathAll", |
| 709 |
"argument": "DBInstances[].DBInstanceStatus", |
| 710 |
"expected": "stopped", |
| 711 |
}, |
| 712 |
], |
| 713 |
}, |
| 714 |
"DBClusterAvailable": { |
| 715 |
"delay": 20, |
| 716 |
"maxAttempts": 60, |
| 717 |
"operation": "DescribeDBClusters", |
| 718 |
"acceptors": [ |
| 719 |
{"state": "success", "matcher": "pathAll", "argument": "DBClusters[].Status", "expected": "available"}, |
| 720 |
{"state": "retry", "matcher": "error", "expected": "DBClusterNotFoundFault"}, |
| 721 |
], |
| 722 |
}, |
| 723 |
"DBClusterDeleted": { |
| 724 |
"delay": 20, |
| 725 |
"maxAttempts": 60, |
| 726 |
"operation": "DescribeDBClusters", |
| 727 |
"acceptors": [ |
| 728 |
{"state": "success", "matcher": "pathAll", "argument": "DBClusters[].Status", "expected": "stopped"}, |
| 729 |
{"state": "success", "matcher": "error", "expected": "DBClusterNotFoundFault"}, |
| 730 |
], |
| 731 |
}, |
| 732 |
"ReadReplicaPromoted": { |
| 733 |
"delay": 5, |
| 734 |
"maxAttempts": 40, |
| 735 |
"operation": "DescribeDBInstances", |
| 736 |
"acceptors": [ |
| 737 |
{ |
| 738 |
"state": "success", |
| 739 |
"matcher": "path", |
| 740 |
"argument": "length(DBInstances[].StatusInfos) == `0`", |
| 741 |
"expected": True, |
| 742 |
}, |
| 743 |
{ |
| 744 |
"state": "retry", |
| 745 |
"matcher": "pathAny", |
| 746 |
"argument": "DBInstances[].StatusInfos[].Status", |
| 747 |
"expected": "replicating", |
| 748 |
}, |
| 749 |
], |
| 750 |
}, |
| 751 |
"RoleAssociated": { |
| 752 |
"delay": 5, |
| 753 |
"maxAttempts": 40, |
| 754 |
"operation": "DescribeDBInstances", |
| 755 |
"acceptors": [ |
| 756 |
{ |
| 757 |
"state": "success", |
| 758 |
"matcher": "pathAll", |
| 759 |
"argument": "DBInstances[].AssociatedRoles[].Status", |
| 760 |
"expected": "ACTIVE", |
| 761 |
}, |
| 762 |
{ |
| 763 |
"state": "retry", |
| 764 |
"matcher": "pathAny", |
| 765 |
"argument": "DBInstances[].AssociatedRoles[].Status", |
| 766 |
"expected": "PENDING", |
| 767 |
}, |
| 768 |
], |
| 769 |
}, |
| 770 |
"RoleDisassociated": { |
| 771 |
"delay": 5, |
| 772 |
"maxAttempts": 40, |
| 773 |
"operation": "DescribeDBInstances", |
| 774 |
"acceptors": [ |
| 775 |
{ |
| 776 |
"state": "success", |
| 777 |
"matcher": "pathAll", |
| 778 |
"argument": "DBInstances[].AssociatedRoles[].Status", |
| 779 |
"expected": "ACTIVE", |
| 780 |
}, |
| 781 |
{ |
| 782 |
"state": "retry", |
| 783 |
"matcher": "pathAny", |
| 784 |
"argument": "DBInstances[].AssociatedRoles[].Status", |
| 785 |
"expected": "PENDING", |
| 786 |
}, |
| 787 |
{ |
| 788 |
"state": "success", |
| 789 |
"matcher": "path", |
| 790 |
"argument": "length(DBInstances[].AssociatedRoles[]) == `0`", |
| 791 |
"expected": True, |
| 792 |
}, |
| 793 |
], |
| 794 |
}, |
| 795 |
}, |
| 796 |
} |
| 797 |
|
| 798 |
|
| 799 |
route53_data = { |
| 800 |
"version": 2, |
| 801 |
"waiters": { |
| 802 |
"ResourceRecordSetsChanged": { |
| 803 |
"delay": 30, |
| 804 |
"maxAttempts": 60, |
| 805 |
"operation": "GetChange", |
| 806 |
"acceptors": [ |
| 807 |
{"matcher": "path", "expected": "INSYNC", "argument": "ChangeInfo.Status", "state": "success"} |
| 808 |
], |
| 809 |
} |
| 810 |
}, |
| 811 |
} |
| 812 |
|
| 813 |
|
| 814 |
def _inject_limit_retries(model): |
| 815 |
extra_retries = [ |
| 816 |
"RequestLimitExceeded", |
| 817 |
"Unavailable", |
| 818 |
"ServiceUnavailable", |
| 819 |
"InternalFailure", |
| 820 |
"InternalError", |
| 821 |
"TooManyRequestsException", |
| 822 |
"Throttling", |
| 823 |
] |
| 824 |
|
| 825 |
acceptors = [] |
| 826 |
for error in extra_retries: |
| 827 |
acceptors.append({"state": "success", "matcher": "error", "expected": error}) |
| 828 |
|
| 829 |
_model = copy.deepcopy(model) |
| 830 |
|
| 831 |
for waiter in model["waiters"]: |
| 832 |
_model["waiters"][waiter]["acceptors"].extend(acceptors) |
| 833 |
|
| 834 |
return _model |
| 835 |
|
| 836 |
|
| 837 |
def ec2_model(name): |
| 838 |
ec2_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(ec2_data)) |
| 839 |
return ec2_models.get_waiter(name) |
| 840 |
|
| 841 |
|
| 842 |
def waf_model(name): |
| 843 |
waf_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(waf_data)) |
| 844 |
return waf_models.get_waiter(name) |
| 845 |
|
| 846 |
|
| 847 |
def eks_model(name): |
| 848 |
eks_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(eks_data)) |
| 849 |
return eks_models.get_waiter(name) |
| 850 |
|
| 851 |
|
| 852 |
def elbv2_model(name): |
| 853 |
elbv2_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(elbv2_data)) |
| 854 |
return elbv2_models.get_waiter(name) |
| 855 |
|
| 856 |
|
| 857 |
def elb_model(name): |
| 858 |
elb_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(elb_data)) |
| 859 |
return elb_models.get_waiter(name) |
| 860 |
|
| 861 |
|
| 862 |
def rds_model(name): |
| 863 |
rds_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(rds_data)) |
| 864 |
return rds_models.get_waiter(name) |
| 865 |
|
| 866 |
|
| 867 |
def route53_model(name): |
| 868 |
route53_models = core_waiter.WaiterModel(waiter_config=_inject_limit_retries(route53_data)) |
| 869 |
return route53_models.get_waiter(name) |
| 870 |
|
| 871 |
|
| 872 |
waiters_by_name = { |
| 873 |
("EC2", "image_available"): lambda ec2: core_waiter.Waiter( |
| 874 |
"image_available", ec2_model("ImageAvailable"), core_waiter.NormalizedOperationMethod(ec2.describe_images) |
| 875 |
), |
| 876 |
("EC2", "internet_gateway_exists"): lambda ec2: core_waiter.Waiter( |
| 877 |
"internet_gateway_exists", |
| 878 |
ec2_model("InternetGatewayExists"), |
| 879 |
core_waiter.NormalizedOperationMethod(ec2.describe_internet_gateways), |
| 880 |
), |
| 881 |
("EC2", "internet_gateway_attached"): lambda ec2: core_waiter.Waiter( |
| 882 |
"internet_gateway_attached", |
| 883 |
ec2_model("InternetGatewayAttached"), |
| 884 |
core_waiter.NormalizedOperationMethod(ec2.describe_internet_gateways), |
| 885 |
), |
| 886 |
("EC2", "transit_gateway_available"): lambda ec2: core_waiter.Waiter( |
| 887 |
"transit_gateway_available", |
| 888 |
ec2_model("TransitGatewayAvailable"), |
| 889 |
core_waiter.NormalizedOperationMethod(ec2.describe_transit_gateways), |
| 890 |
), |
| 891 |
("EC2", "transit_gateway_deleted"): lambda ec2: core_waiter.Waiter( |
| 892 |
"transit_gateway_deleted", |
| 893 |
ec2_model("TransitGatewayDeleted"), |
| 894 |
core_waiter.NormalizedOperationMethod(ec2.describe_transit_gateways), |
| 895 |
), |
| 896 |
("EC2", "transit_gateway_vpc_attachment_available"): lambda ec2: core_waiter.Waiter( |
| 897 |
"transit_gateway_vpc_attachment_available", |
| 898 |
ec2_model("TGWVpcAttachmentAvailable"), |
| 899 |
core_waiter.NormalizedOperationMethod(ec2.describe_transit_gateway_vpc_attachments), |
| 900 |
), |
| 901 |
("EC2", "transit_gateway_vpc_attachment_deleted"): lambda ec2: core_waiter.Waiter( |
| 902 |
"transit_gateway_vpc_attachment_deleted", |
| 903 |
ec2_model("TGWVpcAttachmentDeleted"), |
| 904 |
core_waiter.NormalizedOperationMethod(ec2.describe_transit_gateway_vpc_attachments), |
| 905 |
), |
| 906 |
("EC2", "network_interface_attached"): lambda ec2: core_waiter.Waiter( |
| 907 |
"network_interface_attached", |
| 908 |
ec2_model("NetworkInterfaceAttached"), |
| 909 |
core_waiter.NormalizedOperationMethod(ec2.describe_network_interfaces), |
| 910 |
), |
| 911 |
("EC2", "network_interface_deleted"): lambda ec2: core_waiter.Waiter( |
| 912 |
"network_interface_deleted", |
| 913 |
ec2_model("NetworkInterfaceDeleted"), |
| 914 |
core_waiter.NormalizedOperationMethod(ec2.describe_network_interfaces), |
| 915 |
), |
| 916 |
("EC2", "network_interface_available"): lambda ec2: core_waiter.Waiter( |
| 917 |
"network_interface_available", |
| 918 |
ec2_model("NetworkInterfaceAvailable"), |
| 919 |
core_waiter.NormalizedOperationMethod(ec2.describe_network_interfaces), |
| 920 |
), |
| 921 |
("EC2", "network_interface_delete_on_terminate"): lambda ec2: core_waiter.Waiter( |
| 922 |
"network_interface_delete_on_terminate", |
| 923 |
ec2_model("NetworkInterfaceDeleteOnTerminate"), |
| 924 |
core_waiter.NormalizedOperationMethod(ec2.describe_network_interfaces), |
| 925 |
), |
| 926 |
("EC2", "network_interface_no_delete_on_terminate"): lambda ec2: core_waiter.Waiter( |
| 927 |
"network_interface_no_delete_on_terminate", |
| 928 |
ec2_model("NetworkInterfaceNoDeleteOnTerminate"), |
| 929 |
core_waiter.NormalizedOperationMethod(ec2.describe_network_interfaces), |
| 930 |
), |
| 931 |
("EC2", "route_table_exists"): lambda ec2: core_waiter.Waiter( |
| 932 |
"route_table_exists", |
| 933 |
ec2_model("RouteTableExists"), |
| 934 |
core_waiter.NormalizedOperationMethod(ec2.describe_route_tables), |
| 935 |
), |
| 936 |
("EC2", "security_group_exists"): lambda ec2: core_waiter.Waiter( |
| 937 |
"security_group_exists", |
| 938 |
ec2_model("SecurityGroupExists"), |
| 939 |
core_waiter.NormalizedOperationMethod(ec2.describe_security_groups), |
| 940 |
), |
| 941 |
("EC2", "snapshot_completed"): lambda ec2: core_waiter.Waiter( |
| 942 |
"snapshot_completed", |
| 943 |
ec2_model("SnapshotCompleted"), |
| 944 |
core_waiter.NormalizedOperationMethod(ec2.describe_snapshots), |
| 945 |
), |
| 946 |
("EC2", "subnet_available"): lambda ec2: core_waiter.Waiter( |
| 947 |
"subnet_available", ec2_model("SubnetAvailable"), core_waiter.NormalizedOperationMethod(ec2.describe_subnets) |
| 948 |
), |
| 949 |
("EC2", "subnet_exists"): lambda ec2: core_waiter.Waiter( |
| 950 |
"subnet_exists", ec2_model("SubnetExists"), core_waiter.NormalizedOperationMethod(ec2.describe_subnets) |
| 951 |
), |
| 952 |
("EC2", "subnet_has_map_public"): lambda ec2: core_waiter.Waiter( |
| 953 |
"subnet_has_map_public", |
| 954 |
ec2_model("SubnetHasMapPublic"), |
| 955 |
core_waiter.NormalizedOperationMethod(ec2.describe_subnets), |
| 956 |
), |
| 957 |
("EC2", "subnet_no_map_public"): lambda ec2: core_waiter.Waiter( |
| 958 |
"subnet_no_map_public", |
| 959 |
ec2_model("SubnetNoMapPublic"), |
| 960 |
core_waiter.NormalizedOperationMethod(ec2.describe_subnets), |
| 961 |
), |
| 962 |
("EC2", "subnet_has_assign_ipv6"): lambda ec2: core_waiter.Waiter( |
| 963 |
"subnet_has_assign_ipv6", |
| 964 |
ec2_model("SubnetHasAssignIpv6"), |
| 965 |
core_waiter.NormalizedOperationMethod(ec2.describe_subnets), |
| 966 |
), |
| 967 |
("EC2", "subnet_no_assign_ipv6"): lambda ec2: core_waiter.Waiter( |
| 968 |
"subnet_no_assign_ipv6", |
| 969 |
ec2_model("SubnetNoAssignIpv6"), |
| 970 |
core_waiter.NormalizedOperationMethod(ec2.describe_subnets), |
| 971 |
), |
| 972 |
("EC2", "subnet_deleted"): lambda ec2: core_waiter.Waiter( |
| 973 |
"subnet_deleted", ec2_model("SubnetDeleted"), core_waiter.NormalizedOperationMethod(ec2.describe_subnets) |
| 974 |
), |
| 975 |
("EC2", "vpc_available"): lambda ec2: core_waiter.Waiter( |
| 976 |
"vpc_available", ec2_model("VpcAvailable"), core_waiter.NormalizedOperationMethod(ec2.describe_vpcs) |
| 977 |
), |
| 978 |
("EC2", "vpc_exists"): lambda ec2: core_waiter.Waiter( |
| 979 |
"vpc_exists", ec2_model("VpcExists"), core_waiter.NormalizedOperationMethod(ec2.describe_vpcs) |
| 980 |
), |
| 981 |
("EC2", "vpc_endpoint_exists"): lambda ec2: core_waiter.Waiter( |
| 982 |
"vpc_endpoint_exists", |
| 983 |
ec2_model("VpcEndpointExists"), |
| 984 |
core_waiter.NormalizedOperationMethod(ec2.describe_vpc_endpoints), |
| 985 |
), |
| 986 |
("EC2", "vpn_gateway_exists"): lambda ec2: core_waiter.Waiter( |
| 987 |
"vpn_gateway_exists", |
| 988 |
ec2_model("VpnGatewayExists"), |
| 989 |
core_waiter.NormalizedOperationMethod(ec2.describe_vpn_gateways), |
| 990 |
), |
| 991 |
("EC2", "vpn_gateway_detached"): lambda ec2: core_waiter.Waiter( |
| 992 |
"vpn_gateway_detached", |
| 993 |
ec2_model("VpnGatewayDetached"), |
| 994 |
core_waiter.NormalizedOperationMethod(ec2.describe_vpn_gateways), |
| 995 |
), |
| 996 |
("EC2", "vpn_gateway_attached"): lambda ec2: core_waiter.Waiter( |
| 997 |
"vpn_gateway_attached", |
| 998 |
ec2_model("VpnGatewayAttached"), |
| 999 |
core_waiter.NormalizedOperationMethod(ec2.describe_vpn_gateways), |
| 1000 |
), |
| 1001 |
("EC2", "nat_gateway_deleted"): lambda ec2: core_waiter.Waiter( |
| 1002 |
"nat_gateway_deleted", |
| 1003 |
ec2_model("NatGatewayDeleted"), |
| 1004 |
core_waiter.NormalizedOperationMethod(ec2.describe_nat_gateways), |
| 1005 |
), |
| 1006 |
("EC2", "nat_gateway_available"): lambda ec2: core_waiter.Waiter( |
| 1007 |
"nat_gateway_available", |
| 1008 |
ec2_model("NatGatewayAvailable"), |
| 1009 |
core_waiter.NormalizedOperationMethod(ec2.describe_nat_gateways), |
| 1010 |
), |
| 1011 |
("EC2", "volume_available"): lambda ec2: core_waiter.Waiter( |
| 1012 |
"volume_available", |
| 1013 |
ec2_model("VolumeAvailable"), |
| 1014 |
core_waiter.NormalizedOperationMethod(ec2.describe_volumes), |
| 1015 |
), |
| 1016 |
("EC2", "volume_deleted"): lambda ec2: core_waiter.Waiter( |
| 1017 |
"volume_deleted", |
| 1018 |
ec2_model("VolumeDeleted"), |
| 1019 |
core_waiter.NormalizedOperationMethod(ec2.describe_volumes), |
| 1020 |
), |
| 1021 |
("EC2", "volume_in_use"): lambda ec2: core_waiter.Waiter( |
| 1022 |
"volume_in_use", |
| 1023 |
ec2_model("VolumeInUse"), |
| 1024 |
core_waiter.NormalizedOperationMethod(ec2.describe_volumes), |
| 1025 |
), |
| 1026 |
("WAF", "change_token_in_sync"): lambda waf: core_waiter.Waiter( |
| 1027 |
"change_token_in_sync", |
| 1028 |
waf_model("ChangeTokenInSync"), |
| 1029 |
core_waiter.NormalizedOperationMethod(waf.get_change_token_status), |
| 1030 |
), |
| 1031 |
("WAFRegional", "change_token_in_sync"): lambda waf: core_waiter.Waiter( |
| 1032 |
"change_token_in_sync", |
| 1033 |
waf_model("ChangeTokenInSync"), |
| 1034 |
core_waiter.NormalizedOperationMethod(waf.get_change_token_status), |
| 1035 |
), |
| 1036 |
("EKS", "cluster_active"): lambda eks: core_waiter.Waiter( |
| 1037 |
"cluster_active", eks_model("ClusterActive"), core_waiter.NormalizedOperationMethod(eks.describe_cluster) |
| 1038 |
), |
| 1039 |
("EKS", "cluster_deleted"): lambda eks: core_waiter.Waiter( |
| 1040 |
"cluster_deleted", eks_model("ClusterDeleted"), core_waiter.NormalizedOperationMethod(eks.describe_cluster) |
| 1041 |
), |
| 1042 |
("EKS", "fargate_profile_active"): lambda eks: core_waiter.Waiter( |
| 1043 |
"fargate_profile_active", |
| 1044 |
eks_model("FargateProfileActive"), |
| 1045 |
core_waiter.NormalizedOperationMethod(eks.describe_fargate_profile), |
| 1046 |
), |
| 1047 |
("EKS", "fargate_profile_deleted"): lambda eks: core_waiter.Waiter( |
| 1048 |
"fargate_profile_deleted", |
| 1049 |
eks_model("FargateProfileDeleted"), |
| 1050 |
core_waiter.NormalizedOperationMethod(eks.describe_fargate_profile), |
| 1051 |
), |
| 1052 |
("EKS", "nodegroup_active"): lambda eks: core_waiter.Waiter( |
| 1053 |
"nodegroup_active", eks_model("NodegroupActive"), core_waiter.NormalizedOperationMethod(eks.describe_nodegroup) |
| 1054 |
), |
| 1055 |
("EKS", "nodegroup_deleted"): lambda eks: core_waiter.Waiter( |
| 1056 |
"nodegroup_deleted", |
| 1057 |
eks_model("NodegroupDeleted"), |
| 1058 |
core_waiter.NormalizedOperationMethod(eks.describe_nodegroup), |
| 1059 |
), |
| 1060 |
("ElasticLoadBalancing", "any_instance_in_service"): lambda elb: core_waiter.Waiter( |
| 1061 |
"any_instance_in_service", |
| 1062 |
elb_model("AnyInstanceInService"), |
| 1063 |
core_waiter.NormalizedOperationMethod(elb.describe_instance_health), |
| 1064 |
), |
| 1065 |
("ElasticLoadBalancing", "instance_deregistered"): lambda elb: core_waiter.Waiter( |
| 1066 |
"instance_deregistered", |
| 1067 |
elb_model("InstanceDeregistered"), |
| 1068 |
core_waiter.NormalizedOperationMethod(elb.describe_instance_health), |
| 1069 |
), |
| 1070 |
("ElasticLoadBalancing", "instance_in_service"): lambda elb: core_waiter.Waiter( |
| 1071 |
"load_balancer_created", |
| 1072 |
elb_model("InstanceInService"), |
| 1073 |
core_waiter.NormalizedOperationMethod(elb.describe_instance_health), |
| 1074 |
), |
| 1075 |
("ElasticLoadBalancing", "load_balancer_created"): lambda elb: core_waiter.Waiter( |
| 1076 |
"load_balancer_created", |
| 1077 |
elb_model("LoadBalancerCreated"), |
| 1078 |
core_waiter.NormalizedOperationMethod(elb.describe_load_balancers), |
| 1079 |
), |
| 1080 |
("ElasticLoadBalancing", "load_balancer_deleted"): lambda elb: core_waiter.Waiter( |
| 1081 |
"load_balancer_deleted", |
| 1082 |
elb_model("LoadBalancerDeleted"), |
| 1083 |
core_waiter.NormalizedOperationMethod(elb.describe_load_balancers), |
| 1084 |
), |
| 1085 |
("ElasticLoadBalancingv2", "load_balancer_available"): lambda elbv2: core_waiter.Waiter( |
| 1086 |
"load_balancer_available", |
| 1087 |
elbv2_model("LoadBalancerAvailable"), |
| 1088 |
core_waiter.NormalizedOperationMethod(elbv2.describe_load_balancers), |
| 1089 |
), |
| 1090 |
("ElasticLoadBalancingv2", "load_balancer_ip_address_type_ipv4"): lambda elbv2: core_waiter.Waiter( |
| 1091 |
"load_balancer_ip_address_type_ipv4", |
| 1092 |
elbv2_model("LoadBalancerIpAddressTypeIpv4"), |
| 1093 |
core_waiter.NormalizedOperationMethod(elbv2.describe_load_balancers), |
| 1094 |
), |
| 1095 |
("ElasticLoadBalancingv2", "load_balancer_ip_address_type_dualstack"): lambda elbv2: core_waiter.Waiter( |
| 1096 |
"load_balancers_ip_address_type_dualstack", |
| 1097 |
elbv2_model("LoadBalancerIpAddressTypeDualStack"), |
| 1098 |
core_waiter.NormalizedOperationMethod(elbv2.describe_load_balancers), |
| 1099 |
), |
| 1100 |
("ElasticLoadBalancingv2", "load_balancers_deleted"): lambda elbv2: core_waiter.Waiter( |
| 1101 |
"load_balancers_deleted", |
| 1102 |
elbv2_model("LoadBalancersDeleted"), |
| 1103 |
core_waiter.NormalizedOperationMethod(elbv2.describe_load_balancers), |
| 1104 |
), |
| 1105 |
("RDS", "db_cluster_promoting"): lambda rds: core_waiter.Waiter( |
| 1106 |
"db_cluster_promoting", |
| 1107 |
rds_model("DBClusterPromoting"), |
| 1108 |
core_waiter.NormalizedOperationMethod(rds.describe_db_clusters), |
| 1109 |
), |
| 1110 |
("RDS", "db_instance_stopped"): lambda rds: core_waiter.Waiter( |
| 1111 |
"db_instance_stopped", |
| 1112 |
rds_model("DBInstanceStopped"), |
| 1113 |
core_waiter.NormalizedOperationMethod(rds.describe_db_instances), |
| 1114 |
), |
| 1115 |
("RDS", "cluster_available"): lambda rds: core_waiter.Waiter( |
| 1116 |
"cluster_available", |
| 1117 |
rds_model("DBClusterAvailable"), |
| 1118 |
core_waiter.NormalizedOperationMethod(rds.describe_db_clusters), |
| 1119 |
), |
| 1120 |
("RDS", "cluster_deleted"): lambda rds: core_waiter.Waiter( |
| 1121 |
"cluster_deleted", |
| 1122 |
rds_model("DBClusterDeleted"), |
| 1123 |
core_waiter.NormalizedOperationMethod(rds.describe_db_clusters), |
| 1124 |
), |
| 1125 |
("RDS", "read_replica_promoted"): lambda rds: core_waiter.Waiter( |
| 1126 |
"read_replica_promoted", |
| 1127 |
rds_model("ReadReplicaPromoted"), |
| 1128 |
core_waiter.NormalizedOperationMethod(rds.describe_db_instances), |
| 1129 |
), |
| 1130 |
("RDS", "role_associated"): lambda rds: core_waiter.Waiter( |
| 1131 |
"role_associated", rds_model("RoleAssociated"), core_waiter.NormalizedOperationMethod(rds.describe_db_instances) |
| 1132 |
), |
| 1133 |
("RDS", "role_disassociated"): lambda rds: core_waiter.Waiter( |
| 1134 |
"role_disassociated", |
| 1135 |
rds_model("RoleDisassociated"), |
| 1136 |
core_waiter.NormalizedOperationMethod(rds.describe_db_instances), |
| 1137 |
), |
| 1138 |
("Route53", "resource_record_sets_changed"): lambda route53: core_waiter.Waiter( |
| 1139 |
"resource_record_sets_changed", |
| 1140 |
route53_model("ResourceRecordSetsChanged"), |
| 1141 |
core_waiter.NormalizedOperationMethod(route53.get_change), |
| 1142 |
), |
| 1143 |
} |
| 1144 |
|
| 1145 |
|
| 1146 |
def get_waiter(client, waiter_name): |
| 1147 |
if isinstance(client, RetryingBotoClientWrapper): |
| 1148 |
return get_waiter(client.client, waiter_name) |
| 1149 |
try: |
| 1150 |
return waiters_by_name[(client.__class__.__name__, waiter_name)](client) |
| 1151 |
except KeyError: |
| 1152 |
available_waiters = ", ".join(repr(k) for k in waiters_by_name.keys()) |
| 1153 |
raise NotImplementedError( |
| 1154 |
f"Waiter {waiter_name} could not be found for client {type(client)}. Available waiters: {available_waiters}" |
| 1155 |
) |
| 1156 |
|
| 1157 |
|
| 1158 |
def wait_for_resource_state( |
| 1159 |
client, |
| 1160 |
module: AnsibleAWSModule, |
| 1161 |
waiter_name: str, |
| 1162 |
delay: Optional[int] = None, |
| 1163 |
max_attempts: Optional[int] = None, |
| 1164 |
**params, |
| 1165 |
) -> None: |
| 1166 |
waiter_params = copy.deepcopy(params) |
| 1167 |
if delay is not None or max_attempts is not None: |
| 1168 |
waiter_params["WaiterConfig"] = {} |
| 1169 |
if delay is not None: |
| 1170 |
waiter_params["WaiterConfig"].update({"Delay": delay}) |
| 1171 |
if max_attempts is not None: |
| 1172 |
waiter_params["WaiterConfig"].update({"MaxAttempts": max_attempts}) |
| 1173 |
try: |
| 1174 |
get_waiter(client=client, waiter_name=waiter_name).wait(**waiter_params) |
| 1175 |
except exception_waiter.WaiterError as e: |
| 1176 |
module.fail_json_aws(e, f"Timeout waiting for '{waiter_name}'") |
| 1177 |
except (exception_waiter.ClientError, exception_waiter.BotoCoreError) as e: |
| 1178 |
module.fail_json_aws(e, f"An exception happened while trying to wait for '{waiter_name}'") |