Created
May 18, 2020 18:14
-
-
Save ashutoshkarna03/7cac8cb8b0d4c653bdac4ca484583eeb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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