Last active
August 29, 2015 14:02
-
-
Save agbodike/78149a8c4ecd634b69d9 to your computer and use it in GitHub Desktop.
Prepping an Opworks instance for an AMI.
This file contains 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
Overview instructions: | |
http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html | |
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html | |
https://dev.infopark.net/e7832b631baf0ce8/creating-an-instance-store-backed-ami-from-a-running-opsworks-instance | |
Make a very very big powerful box (or else you'll sit there forever waiting for the image to zip up) | |
SSH into a running blank opsworks box | |
Do whatever crazy stuff you need to do (install packages, root kits, etc) | |
Do the stuff at the bottom of here to kill off existing opsworks packages: | |
http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html | |
Gen dummy X.509 keys: | |
openssl req -x509 -newkey rsa:2048 -keyout private_key.pem -out cert.pem -days 365 -nodes -batch | |
Setup ec2-bundle (or AMI tools) | |
http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/set-up-ami-tools.html | |
Make sure ec2-ami-tools are installed under both users (ubuntu & root) | |
export EC2_AMITOOL_HOME=/usr/local/ec2/ec2-ami-tools-x.x.x.x | |
export PATH=$EC2_AMITOOL_HOME/bin:$PATH | |
ec2-ami-tools-version | |
Find your account ID under IAM => user => summary | |
Should look something like: | |
User ARN: arn:aws:iam::##########:user/Bob | |
Tweaked ec2-bundle command: | |
mkdir -p /tmp/bundle && $EC2_AMITOOL_HOME/bin/ec2-bundle-vol -k private_key.pem -c cert.pem -u <acct id> -r x86_64 -e /tmp/cert -d /tmp/bundle --no-filter | |
# Upload generated bundle | |
ec2-upload-bundle -b fc-us-amis/rabbitmq-20140606_v2 -m /tmp/bundle/image.manifest.xml -a your_access_key_id -s your_secret_access_key --region us-east-1 | |
Install amazon cli tools on your local dev machine to register the ami | |
brew install python | |
pip install amwcli | |
Register image: | |
AWS_DEFAULT_REGION=us-east-1 aws ec2 register-image --image-location fc-us-amis/rabbitmq-20140606_v1/image.manifest.xml --name "Ubuntu-12_04-Rabbit-3_3_1-v2" | |
Fire up the box and pray to some amazon gods that it works. Do not use too large of a box? (m3.medium seems to work). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment