Thursday, July 23, 2009

Creating a Paid LINUX AMI

The Amazon documentation is here, but all examples don't work well. This blog is better. Most of the information below is reproduced from the above Blog. Here I am listing out all the things you need to do assuming you are creating an image from scratch

First you need the following
  • User name/password of your Amazon acct
  • Your account number. This is of the form of XXXX-XXXX-XXX. You can get it from the mail that Amazon sent you when you created the account or from your access identifiers page
  • AWS access key: Looks like this AKIAIJAEHQEJP1PCA4IL. You can get it from the mail that Amazon sent you when you created the account or from your access identifiers page
  • Secret key : Looks like this 5dgaxfawHIkan63XHAKDFJ3Jsdmfg9HAS. You can get it from the mail that Amazon sent you when you created the account or from your access identifiers page
  • AMI Id of the starter image that you want to create your image from
  • Dev pay product code. If you don;t have this, sing up for devpay using your amazon account. You will get a product code at the end
  1. Login to your access identifiers page
  2. If you haven't already, generate a new private key and certificate. Download this private key and certificate to your local machine. The private key will be named pk-XXXXXX.pem, The certificate is named cert-XXXXXX.pem. Protect these 2 files and do not share them publicly. These 2 files have private keys to your account. Also, if you are managing multiple Amazon accounts, make sure you don't mix the keys together
  3. Login to AWS console
  4. Create a key pair. Download the private key for the key pair into your local machine
  5. Start an instance using the starter AMI using the key pair that you just created
  6. SSH into this instance. (If you are using PUTTY, follow these instructions to create a ppk file)
  7. Create a directory named /mnt/bundle. We will create the image here. Also we will store your private keys here. It is important that the image be created in /mnt since by default /mnt is excluded from bundling. You don;t want your private keys to be bundled into the image
  8. copy the private key and certificate file to /mnt/bundle (If you are on windows use WinSCP)
  9. Bundle your image
    cd /mnt/bundle\
    ec2-bundle-vol -k pk-AAA...ZZZ.pem -c cert-AAA...ZZZ.pem -u -d /mnt/bundle/ -p

  10. Wait. This will take some time. It will create a file named .manifest.xml, along with files named .part.nn
  11. Login to S3 organizer
  12. Create a bucket
  13. Upload the image to the bucket
    ec2-upload-bundle -b  -m .manifest.xml -a  -s 

  14. Wait. The image will be copied over to the bucket
  15. Register this image as an AMI using the AWS console. At this point your image is bundled. But no one else except you can use it. Now you have to turn this into a paid AMI
  16. go back to SSH console. You might need to setup the following envioroment variables in order to run the following commands
    EC2_HOME
    JAVA_HOME

  17. Run the following command to associate your AMI with your devpay product
    ec2-modify-image-attribute --product-code -K pk-XXXX.pem -C cert-XXX.pem


No comments:

Post a Comment