home_button_01 aboutus_button_01 services_button_01 contactus_button_01
Mar 9th, 2010 at 4:09 PM
Home arrow Publications arrow Amazon EC2 AMI Creation and Upload
Amazon EC2 AMI Creation and Upload PDF Print E-mail
Cloud computing is the future and Amazon's AWS system is leading the charge. Here is a script we've written to help new comers learn how to start a linux instance, modify it for their needs, and save the instance for later use in S3.
#!/bin/sh

#
#       (C) Valley Technologies, LLC. 2009 All rights reserved.
#

#
#       What is this AMI's named?
#
IMAGE_NAME="VTech.General"

#
#       Just a little clean up
#
if [ -f /root/.bash_history ]; then rm /root/.bash_history; fi

#
#       What S3 bucket do you want to put the AMI image in?
#
s3Bucket="default"

#
#       What is your S3 Access Key ID? 
#       http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key
#
s3AccessID=""

#
#       What is your S3 Secret Access Key? 
#       http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key
#
s3SecretKey=""

#
#       Full path to the Amazon issued private key file - like pk-ZXE2357889KXXNEXX23454677XX.pem
#       You should have already downloaded this and saved it when it was created. See thread:
#       http://developer.amazonwebservices.com/connect/thread.jspa?threadID=27081
#
pk_file="/root/pk.pem"

#
#       Full path to the Amazon issued certificate file - like cert-ZXE23456XXXJKXXN788654X4XXBXX.pem
#       http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key
#
cert_file="/root/cert.pem"

#
#       Amazon Account - find on the Account Activity page - all numeric
#       https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key
#       EXAMPLE: 9375-0289-1234 , keep the dashes
#
ec2_account=""

#
#       OPTIONAL: Comma seperated path of dir's to ignore when we create the image, comment out to disable
#
ign_dir="-e /mnt/vhome"

#
##################################################################################################################################
##################################################################################################################################
#

# clean up the old stuff
if [ -f /mnt/${IMAGE_NAME}.manifest.xml ]
then
        rm -rf /mnt/${IMAGE_NAME}*
fi

# create an image of this system
ec2-bundle-vol -k $pk_file -c $cert_file -u $ec2_account --arch i386 -d /mnt/ $ign_dir -p $IMAGE_NAME

# upload to S3, ignore the SSL error
ec2-upload-bundle --url http://s3.amazonaws.com -b $s3Bucket -m /mnt/$IMAGE_NAME.manifest.xml -a $s3AccessID -s $s3SecretKey

# register your AMI so it's available to you under 'AMI's Owned By Me'
ec2-register -K $pk_file -C $cert_file ${s3Bucket}/${IMAGE_NAME}.manifest.xml
 
Next >
Main Menu
Home
About Us
Services
Contact Us
Publications
Links
Search
Accounting
Pay Online
Billing Policies
Remote Help
Security Updates
Monitoring Services
Bandwidth Test
VoIP Bandwidth Test
Employment Questionnaire
In/Out Board
Login Form





Lost Password?

© 2004-2010 Valley Technologies, LLC. All rights reserved.