Last active
January 15, 2018 11:02
-
-
Save mochizuki-masao/70fff03d9be5fe80dfb43a05b13556a0 to your computer and use it in GitHub Desktop.
Copy EC2 AMI Permission to another AMI
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
#!/bin/bash | |
source_ami=ami-xxxxxxx | |
dest_ami=ami-yyyyyyy | |
aws ec2 modify-image-attribute \ | |
--image-id ${dest_ami} \ | |
--attribute launchPermission \ | |
--operation-type add \ | |
--user-ids $(aws ec2 describe-image-attribute --image-id ${source_ami} --attribute launchPermission \ | |
| jq -r '.LaunchPermissions[].UserId' | tr '\n' ' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment