Skip to content

Instantly share code, notes, and snippets.

@ashutoshkarna03
Created May 18, 2020 18:12
Show Gist options
  • Save ashutoshkarna03/4f86a96e0244802980ad943d4a48bfd5 to your computer and use it in GitHub Desktop.
Save ashutoshkarna03/4f86a96e0244802980ad943d4a48bfd5 to your computer and use it in GitHub Desktop.
def create_image_of_instance(instance_id, client):
waiter = client.get_waiter('image_available')
# call create_image to create AMI of given instance
response = client.create_image(InstanceId=instance_id, Name="latest-image-of-" + instance_id)
print('Creating image, this may take few minutes...')
waiter.wait(ImageIds=[response['ImageId']], DryRun=False)
return response['ImageId']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment