Skip to content

Instantly share code, notes, and snippets.

@vpack
Created February 2, 2016 02:09
Show Gist options
  • Save vpack/8d7cb86af2a706996f71 to your computer and use it in GitHub Desktop.
Save vpack/8d7cb86af2a706996f71 to your computer and use it in GitHub Desktop.
Sharing AWS AMIs with other AWS accounts
touch ~/.boto
rm ~/.boto
AMI=ami-284d6242
accounts="1 2 3 4 5"
echo "Current permissions :"
aws ec2 --region us-east-1 describe-image-attribute --image-id $AMI --attribute launchPermission
for act in $accounts
do
echo $act
aws ec2 --region us-east-1 modify-image-attribute --image-id $AMI --launch-permission "{\"Add\": [{\"UserId\":\"$act\"}]}"
done
echo "Updated permissions :"
aws ec2 --region us-east-1 describe-image-attribute --image-id $AMI --attribute launchPermission
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment