Using an AMI

From PrgmrWiki

http://docs.amazonwebservices.com/AWSEC2/2008-05-05/GettingStartedGuide/


So there are many pre-made amazon machine images...

here is one convenient list

http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=101&resultOffset=0&sortField=9&sortOrder=0&filterEntryTypeID=-1


Unfortunately, to actually download an image, it looks like I need to re package it...

http://developer.amazonwebservices.com/connect/message.jspa?messageID=72369

so ok, now I need the ec2 tools:

wget 'http://www.amazon.com/gp/redirect.html/ref=aws_rc_ec2tools?location=http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip&token=A80325AA4DAB186C80828ED5138633E3F49160D9'

 unzip ec2-api-tools.zip 

next I need to download the certificate and private key from ec2

now I need to set some environment variables

export EC2_HOME=/home/lsc/ec2/ec2-api-tools-1.3-19403
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
export JAVA_HOME=/usr/java/default


and now 


 ./bin/ec2dim -x all

gives me a huge number of images.  

I'm going back to the list I referenced at the begining-  I'm using a image I see with ami id 



if you see Client.InvalidSecurity: Request has expired

that means your clock is wrong.  setup ntpd or ntpdate


ok, so now I go bak to the list at the beining and select a image.  ami id ami-d8a347b1.


[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-run-instances ami-d8a347b1
RESERVATION     r-cf8549a6      523861150215    default
INSTANCE        i-6c3ced05      ami-d8a347b1                    pending        0m1.small        2008-07-04T06:12:22+0000        us-east-1a      aki-9b00e5f2


[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-describe-instances 
RESERVATION     r-cf8549a6      523861150215    default
INSTANCE        i-6c3ced05      ami-d8a347b1                    pending        0m1.small        2008-07-04T06:12:22+0000        us-east-1a      aki-9b00e5f2
[lsc@localhost ec2-api-tools-1.3-19403]$ 

[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-terminate-instances  i-6c3ced05
 

INSTANCE        i-6c3ced05      running shutting-down
[lsc@localhost ec2-api-tools-1.3-19403]$ 
[lsc@localhost ec2-api-tools-1.3-19403]$ 
[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-describe-instances
RESERVATION     r-cf8549a6      523861150215    default
INSTANCE        i-6c3ced05      ami-d8a347b1    ec2-75-101-206-8.compute-1.amazonaws.com        domU-12-31-39-00-85-53.compute-1.internal       shutting-down  0m1.small        2008-07-04T06:12:22+0000        us-east-1a      aki-9b00e5f2
[lsc@localhost ec2-api-tools-1.3-19403]$ 
[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-describe-instances
RESERVATION     r-cf8549a6      523861150215    default
INSTANCE        i-6c3ced05      ami-d8a347b1                    terminated     0m1.small        2008-07-04T06:12:22+0000                aki-9b00e5f2




 bin/ec2-add-keypair  test >test.id



[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-run-instances ami-d8a347b1 -k test
RESERVATION     r-d0824eb9      523861150215    default
INSTANCE        i-7b25f412      ami-d8a347b1                    pending test   0m1.small        2008-07-04T10:02:31+0000        us-east-1c      aki-9b00e5f2


[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-authorize default -p 22
GROUP           default
PERMISSION              default ALLOWS  tcp     22      22      FROM    CIDR   0.0.0.0/0




[lsc@localhost ec2-api-tools-1.3-19403]$ bin/ec2-describe-instances
RESERVATION     r-23824e4a      523861150215    default
INSTANCE        i-f322f39a      ami-d8a347b1                    terminated     test     0               m1.small        2008-07-04T09:48:47+0000               aki-9b00e5f2
RESERVATION     r-d0824eb9      523861150215    default
INSTANCE        i-7b25f412      ami-d8a347b1    ec2-75-101-224-65.compute-1.amazonaws.com       ip-10-251-203-52.ec2.internal   running test    0              m1.small 2008-07-04T10:02:31+0000        us-east-1c      aki-9b00e5f2
[lsc@localhost ec2-api-tools-1.3-19403]$ ls
bin                                        test.privatekey
cert-EDDLUNQALNWCJSWRLVML42FRT6JEBFT6.pem  THIRDPARTYLICENSE.TXT
lib                                        vars.sh
pk-EDDLUNQALNWCJSWRLVML42FRT6JEBFT6.pem
[lsc@localhost ec2-api-tools-1.3-19403]$ mv test.privatekey test.id
[lsc@localhost ec2-api-tools-1.3-19403]$ ssh -i test.id lsc@ec2-75-101-224-65.compute-1.amazonaws.com



[lsc@localhost ec2-api-tools-1.3-19403]$ chmod 600 test.id
[lsc@localhost ec2-api-tools-1.3-19403]$ ssh -i test.id root@ec2-75-101-224-65.compute-1.amazonaws.com
     ___   _        __   __   ____            __    
    / _ \ (_)___ _ / /  / /_ / __/____ ___ _ / /___ 
   / , _// // _ `// _ \/ __/_\ \ / __// _ `// // -_)
  /_/|_|/_/ \_, //_//_/\__//___/ \__/ \_,_//_/ \__/ 
           /___/                                                 
                                              
Welcome to a public Amazon EC2 image brought to you by RightScale!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!       Your EC2 Instance has failed installation.             !!!
!!!       Please check /var/log/install for details.             !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




now... to bundle again.

from teh local box

[lsc@localhost ec2-api-tools-1.3-19403]$ scp -i test.id *.pem root@ec2-75-101-224-65.compute-1.amazonaws.com:~/
cert-EDDLUNQALNWCJSWRLVML42FRT6JEBFT6.pem     100%  916     0.9KB/s   00:00    
pk-EDDLUNQALNWCJSWRLVML42FRT6JEBFT6.pem       100%  926     0.9KB/s   00:00    
[lsc@localhost ec2-api-tools-1.3-19403]$ 



ssh back into the image:

[root@ip-10-251-203-52:~] ec2-bundle-vol  --cert cert-EDDLUNQALNWCJSWRLVML42FRT6JEBFT6.pem  --privatekey pk-EDDLUNQALNWCJSWRLVML42FRT6JEBFT6.pem  --user 123456789012 -s 1024
Please specify a value for arch [i386]: 
Copying / into the image file /tmp/image...
Excluding: 
         /sys
         /var/lib/nfs/rpc_pipefs
         /proc
         /dev/pts
         /proc/sys/fs/binfmt_misc
         /dev
         /media
         /mnt
         /proc
         /sys
         /tmp/image
         /mnt/img-mnt
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.002646 seconds, 396 MB/s
mke2fs 1.39 (29-May-2006)





execution failed: "rsync -rlpgoD -t -r -S -l --exclude /sys --exclude /var/lib/nfs/rpc_pipefs --exclude /proc --exclude /dev/pts --exclude /proc/sys/fs/binfmt_misc --exclude /dev --exclude /media --exclude /mnt --exclude /proc --exclude /sys --exclude /tmp/image --exclude /mnt/img-mnt -X /* /mnt/img-mnt 2>&1 > /dev/null"
ec2-bundle-vol failed.


perhaps I need a real -u value?