mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Unpack AWS reservations while waiting to terminate (#4012)
Previously calculation of the number of instances that have been terminated assumed all instances were in the first reservation returned by AWS. If this is not the case the calculated number of instances terminated never reaches the number of instances and the module always times out. By unpacking the instances we get an accurate number and the module correctly exits.
This commit is contained in:
parent
1a02005b8d
commit
f916dae700
1 changed files with 1 additions and 1 deletions
|
@ -1233,7 +1233,7 @@ def terminate_instances(module, ec2, instance_ids):
|
|||
instance_ids=terminated_instance_ids, \
|
||||
filters={'instance-state-name':'terminated'})
|
||||
try:
|
||||
num_terminated = len(response.pop().instances)
|
||||
num_terminated = sum([len(res.instances) for res in response])
|
||||
except Exception as e:
|
||||
# got a bad response of some sort, possibly due to
|
||||
# stale/cached data. Wait a second and then try again
|
||||
|
|
Loading…
Reference in a new issue