I have a EC2 instance A which must NOT be rebooted, but the problem is that it's going to be down for maintenance. I basically create a AMI of this instance using my code as follows:
import boto.ec2
import time
import sys
conn = boto.ec2.connect_to_region("ap-southeast-1")
image_id = conn.create_image(sys.argv[1], "nits", description="Testing", no_reboot=True, block_device_mapping=None, dry_run=False)
image = conn.get_all_images(image_ids=[image_id])[0]
while image.state != 'available':
time.sleep(10)
image.update()
print "The image is being Created, Please wait!! state:%s" % (image.state)
if image.state == 'available':
print "AMI CREATED SUCCESSFULLY with AMI id = %s" % image_id
else:
print "Something Went Wrong!!"
The above script works fine and creates an AMI of the instance that I provide as a system argument. I need to launch a EXACT SAME REPLICA of the instance "A" , i.e the instance that need to be launched needs to have the same VPC, sec group, key name etc.. i am thinking that i need to store the instance A's details in a variable and then use them to launch a new instance from the AMI or something like that..
Aucun commentaire:
Enregistrer un commentaire