diff --git a/cloud/amazon/ec2.py b/cloud/amazon/ec2.py index 5f69ab978b7..3bc6e4d37a2 100644 --- a/cloud/amazon/ec2.py +++ b/cloud/amazon/ec2.py @@ -1236,7 +1236,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