Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ashutoshkarna03/7cac8cb8b0d4c653bdac4ca484583eeb to your computer and use it in GitHub Desktop.
Save ashutoshkarna03/7cac8cb8b0d4c653bdac4ca484583eeb to your computer and use it in GitHub Desktop.
def copy_image_to_destination_region(image_id, instance_id, client):
waiter = client.get_waiter('image_available')
source_region = os.getenv('SOURCE_REGION')
# call copy_image to copy the AMI from source region to destination
response = client.copy_image(
Description='Copied image of instance: ' + instance_id + ' from region: ' + source_region,
Name='new image of instance ' + instance_id,
SourceImageId=image_id,
SourceRegion=source_region,
)
new_image_id = response['ImageId']
print('Copying image, this may take few minutes...')
waiter.wait(ImageIds=[new_image_id], DryRun=False)
return new_image_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment