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, \
|
instance_ids=terminated_instance_ids, \
|
||||||
filters={'instance-state-name':'terminated'})
|
filters={'instance-state-name':'terminated'})
|
||||||
try:
|
try:
|
||||||
num_terminated = len(response.pop().instances)
|
num_terminated = sum([len(res.instances) for res in response])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# got a bad response of some sort, possibly due to
|
# got a bad response of some sort, possibly due to
|
||||||
# stale/cached data. Wait a second and then try again
|
# stale/cached data. Wait a second and then try again
|
||||||
|
|
Loading…
Reference in a new issue