aws boto 停止 和 删除实例

停止实例

import boto.ec2

region = ""
aws_access_key_id = ""
aws_secret_access_key = ""

conn = boto.ec2.connect_to_region(region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)

instance_list = []

conn.stop_instances(instance_ids=instance_list)

删除实例

import boto.ec2

region = ""
aws_access_key_id = ""
aws_secret_access_key = ""

conn = boto.ec2.connect_to_region(region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)

instance_list = []

for instance in instance_list :
 conn.modify_instance_attribute(instance, "disableApiTermination", False)

conn.terminate_instances(instance_ids=instance_list)

发表评论

电子邮件地址不会被公开。 必填项已用*标注