I'm going to write down what I do when I create an EC2 instance "from scratch". First, I don't really start from scratch, I start at alestic.com and I use the latest Ubuntu 64 bit server. In this case, I'm going to use ami-55739e3c which is Ubuntu 9.10 Karmic Canonical in the US East 1 region. I've installed the EC2 command line tools already.
$ ec2-run-instances --region us-east-1 -g ssh -k sg-key-pair -t m1.large ami-55739e3c
Of course, I had already created the keypair (sg-key-pair) and the group (ssh).
Now, wait for the instance to start up:
$ ec2-describe-instances i-xxxxxxx
The i-xxxxxx is the instance ID given in the output of the ec2-run-instances command. Wait for the status to be 'running'.
Now log into the host:
$ ssh -i [keypair file] ubuntu@[EC2 host]
You're in, now update the host:
$ sudo -s # apt-get update # apt-get upgrade
My next steps are based off of these instructions: http://alestic.com/2009/06/ec2-ami-bundle. Here's what I do:
Add the following lines to /etc/apt/sources.list to get Multiverse packages
deb <a href="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/" title="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/">http://us-east-1.ec2.archive.ubuntu.com/ubuntu/</a> karmic multiverse deb-src <a href="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/" title="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/">http://us-east-1.ec2.archive.ubuntu.com/ubuntu/</a> karmic multiverse deb <a href="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/" title="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/">http://us-east-1.ec2.archive.ubuntu.com/ubuntu/</a> karmic-updates multiverse deb-src <a href="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/" title="http://us-east-1.ec2.archive.ubuntu.com/ubuntu/">http://us-east-1.ec2.archive.ubuntu.com/ubuntu/</a> karmic-updates multiverse
Add tools to bundle an AMI
# apt-get update # apt-get install ec2-ami-tools
Copy up your cert and private key from your desktop to your EC2 instance
$ scp -i [keypair file] [cert file] [private key file] ubuntu@[EC2 host]:/tmp
Now, bundle the volume
# ec2-bundle-vol -r x86_64 -d /mnt -p ubuntu-karmic-9.10-64bit-base-16MAR2010 -u [AWS account number] -k /tmp/pk -c /tmp/cert -s 10240 -e /mnt,/root/.ssh,/home/ubuntu/.ssh # ec2-upload-bundle -b com.soundgardenworld.amis -m /mnt/ubuntu-karmic-9.10-64bit-base-16MAR2010.manifest.xml -a [AWS Access Key] -s [AWS Secret Key]
Back on your desktop, register your now AMI
$ ec2-register --name ubuntu-karmic-9.10-64bit-base-16MAR2010 [s3 bucket]/ubuntu-karmic-9.10-64bit-base-16MAR2010.manifest.xml
- ian's blog
- Login or register to post comments