Skip to content

Instantly share code, notes, and snippets.

@mochizuki-masao
Last active January 15, 2018 11:02
Show Gist options
  • Save mochizuki-masao/70fff03d9be5fe80dfb43a05b13556a0 to your computer and use it in GitHub Desktop.
Save mochizuki-masao/70fff03d9be5fe80dfb43a05b13556a0 to your computer and use it in GitHub Desktop.
Copy EC2 AMI Permission to another AMI
#!/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