Skip to content

Instantly share code, notes, and snippets.

@seventhskye
Created September 10, 2015 09:57
Show Gist options
  • Save seventhskye/c9ee9b86c7ea227770c0 to your computer and use it in GitHub Desktop.
Save seventhskye/c9ee9b86c7ea227770c0 to your computer and use it in GitHub Desktop.
Bash wrapper to create an Amazon Machine Image when logged into an instance. The IAM profile or keys must have the statement specified.
#!/bin/bash
# "Statement": [
# {
# "Effect": "Allow",
# "Action": [
# "ec2:CreateImage",
# "ec2:RegisterImage"
# ],
# "Resource": "*"
# }
# ]
NAME=
DESCRIPTION=
aws ec2 create-image \
--name $NAME-`date +%s` \
--instance-id $(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id) \
--description $DESCRIPTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment