Amazon EC2 cloud setup
Initial Set Up
Following the instructions with Amazon documentation: Getting Started Guide
You have your account setup, and credit card submitted.
Going to use the Java toolset, lookup where java is installed on hgwdev, set environment:
JAVA_HOME=/usr/java/jre1.6.0_11
From your Amazon account management screen, save the cert-*.pem and pk-*.pem files and save in your home directory ~/.ec2/ directory, chmod 700 ~/.ec2/ for security, and set the files at chmod 600 to be read-only for yourself.
Set environment:
EC2_PRIVATE_KEY=$HOME/.ec2/pk-*.pem EC2_CERT=$HOME/.ec2/cert-*.pem
Record your Amazon account number for later reference, it looks like: 1234-5678-9012
Pick up Java toolset from: Java Toolset
Unpack in some directory, and set environment:
EC2_HOME=/some/directory/ec2-api-tools-1.3-34128
Add $EC2_HOME/bin to your PATH
And to protect Java from the huge memory on hgwdev, set environment:
EC2_JVM_ARGS=-Xmx256M
Verify regions available with the toolset command:
$ ec2-describe-regions
Which responds:
REGION eu-west-1 eu-west-1.ec2.amazonaws.com REGION us-east-1 us-east-1.ec2.amazonaws.com
Set environment:
EC2_URL=https://us-east-1.ec2.amazonaws.com
Create SSH keys:
$ cd $HOME/.ssh $ ec2-add-keypair gsg-keypair > id_rsa.gsg-keypair $ chmod 600 id_rsa-gsg-keypair
Sample AMI Images
Initial sample images are listed with:
$ ec2-describe-images -o self -o amazon > describe-images.txt
And, we want to use this one for a test first:
$ grep getting-started.manifest describe-images.txt
Responds:
IMAGE ami-3c47a355 ec2-public-images/getting-started.manifest.xml ... etc...
Note the identification ami-3c47a355, used in this command:
$ ec2-run-instances ami-3c47a355 -k gsg-keypair
Which responds:
RESERVATION r-cee26ea7 891631566226 default INSTANCE i-32a7c65b ami-3c47a355 pending gsg-keypair 0 m1.small 2009-04-02T22:47:17+0000 us-east-1c aki-a71cf9ce ari-a51cf9cc
Means it is running, Note the instance identification: i-32a7c65b
Use in this command to display the status of the instance:
$ ec2-describe-instances i-32a7c65b
Which responds:
RESERVATION r-cee26ea7 891631566226 default INSTANCE i-32a7c65b ami-3c47a355 ec2-72-44-35-57.compute-1.amazonaws.com domU-12-31-39-03-46-52.compute-1.internal running gsg-keypair 0m1.small 2009-04-02T22:47:17+0000 us-east-1c aki-a71cf9ce ari-a51cf9cc
Note the name of the machine in that output: ec2-72-44-35-57.compute-1.amazonaws.com
Open SSH and HTTP ports:
$ ec2-authorize default -p 22 $ ec2-authorize default -p 80
responds:
GROUP default PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0 GROUP default PERMISSION default ALLOWS tcp 80 80 FROM CIDR 0.0.0.0/0
You can now see the Apache WEB server at: http://ec2-72-44-35-57.compute-1.amazonaws.com/
To see SSH keys:
$ ec2-get-console-output i-32a7c65b
Responds:
ec2: 2048 92:81:4f:19:e6:5b:23:e6:78:b7:e2:5d:be:ea:70:1d /etc/ssh/ssh_host_key.pub ec2: 2048 20:9d:15:98:f6:71:fc:8d:4f:82:b6:e7:3f:76:e0:cc /etc/ssh/ssh_host_rsa_key.pub ec2: 1024 4f:18:83:90:7b:11:be:c3:b4:c5:7a:a3:11:9d:26:76 /etc/ssh/ssh_host_dsa_key.pub
Login via ssh to this system:
$ ssh -i $HOME/.ssh/id_rsa.gsg-keypair root@ec2-72-44-35-57.compute-1.amazonaws.com
Verify the displayed RSH key is one of those from the console-output command:
RSA key fingerprint is 20:9d:15:98:f6:71:fc:8d:4f:82:b6:e7:3f:76:e0:cc. Are you sure you want to continue connecting (yes/no)? yes
__| __|_ ) Fedora 8 _| ( / 32-bit ___|\___|___| Welcome to an EC2 Public Image :-) Getting Started --[ see /etc/ec2/release-notes ]-- [root@domU-12-31-39-03-46-52 ~]#
There is your login prompt. You are now a system administrator.
Turning Off an Image
$ ec2-terminate-instances i-32a7c65b INSTANCE i-32a7c65b running shutting-down