From 9d9d8def6f678f9b27e20aa8990e349280e0514a Mon Sep 17 00:00:00 2001 From: Benno Joy Date: Thu, 14 May 2015 08:29:11 +0530 Subject: [PATCH] fixe issue #600, where ec2 module returns instance state as runing even after instance is terminated --- cloud/amazon/ec2.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cloud/amazon/ec2.py b/cloud/amazon/ec2.py index 09a4082428b..62f0994954f 100755 --- a/cloud/amazon/ec2.py +++ b/cloud/amazon/ec2.py @@ -1089,6 +1089,13 @@ def terminate_instances(module, ec2, instance_ids): # waiting took too long if wait_timeout < time.time() and num_terminated < len(terminated_instance_ids): module.fail_json(msg = "wait for instance termination timeout on %s" % time.asctime()) + #Lets get the current state of the instances after terminating - issue600 + instance_dict_array = [] + for res in ec2.get_all_instances(instance_ids=terminated_instance_ids,\ + filters={'instance-state-name':'terminated'}): + for inst in res.instances: + instance_dict_array.append(get_instance_info(inst)) + return (changed, instance_dict_array, terminated_instance_ids)