add logic in case instances are already died

pull/37/head
Minh Doan 6 years ago
parent 44ebda38b4
commit 3a8a059f8f
  1. 3
      aws-experiment-launch/terminate_instances.py

@ -10,10 +10,13 @@ def terminate_instances_by_region(region_number, region_config):
ec2_client, _ = utils.create_ec2_client(region_number, args.region_config)
filters = [{'Name': 'tag:Name','Values': [node_name_tag]}]
instance_ids = utils.get_instance_ids(ec2_client.describe_instances(Filters=filters))
if instance_ids:
ec2_client.terminate_instances(InstanceIds=instance_ids)
print "waiting until instances with tag %s died." % node_name_tag
waiter = ec2_client.get_waiter('instance_terminated')
waiter.wait(InstanceIds=instance_ids)
else:
print 'there is no instances to terminate'
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='This script helps you to collect public ips')

Loading…
Cancel
Save