Difference between revisions of "Aws-build"
Line 130: | Line 130: | ||
− | + | '''Mac OS X users''' |
|
The file to be used is `/etc/bashrc` and the lines to be added at the end of the file are: |
The file to be used is `/etc/bashrc` and the lines to be added at the end of the file are: |
||
Revision as of 21:05, 14 February 2011
Building an AMI
Installing AMI Tools
- Download the AMI Tools RPM available Amazon:
wget https://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
- Install the downloaded RPM:
# rpm -ivh ec2-ami-tools.noarch.rpm Preparing... ########################################### [100%] 1:ec2-ami-tools ########################################### [100%]
- In order to isolate the resulting files create a new folder and put the image there:
# mkdir /usr/local/src/EC2/bundle # mv /usr/local/src/EC2/bashlinux-general-server.fs /usr/local/src/EC2/bundle # cd /usr/local/src/EC2/bundle
- Bundle the image
# ec2-bundle-image -i bashlinux-general-server.fs -k pk-ABCDEFGHI1ABCDEFG2ABC3ABCD45ABC.pem -c cert-ABCDEFGHI1ABCDEFG2ABC3ABCD45ABC.pem -u 123456789012
It will splits and encrypts the image into manageable parts for upload.
- -i refers to the name of the image.
- -k refers to the Private Key file.
- -c refers to the Certificate file.
- -u refers to the user ID that is the AWS account ID without dashes.
- Upload the bundle image
# ec2-upload-bundle -b bashlinux -m /tmp/bashlinux-general-server.fs.manifest.xml -a <access_key> -s <secret_key>
- -b refers the target bucket, use bashlinux.
- -m refers to the manifest that was created by `ec2-bundle-image` command and placed on `/tmp` folder
- <access_key> is your AWS Access Key.
- <secret_key> is your AWS Secret Key.
Installing API tools
The API tools is a set of command-line executable files created in Java, them come in a zip file ready to use in both systems, Linux and Windows.
- Download API tools from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88
- Decompress the file and place the content under /opt
# cd /opt # unzip ec2-api-tools.zip
- Set the environment variable for EC2 API tools
# export EC2_HOME=/opt/ec2-api-tools-1.3-19403
- Add the _bin_ directory of API tools to the system path
# export PATH=$PATH:$EC2_HOME/bin
To simplify the work environment calling the commands from anywhere in the system and avoid to write long lines to run a command we might want to set up the environment variables to have done it.
Setting up Private Key and Certificate for authentication
- Place private key and certification into a secure and accessible location
# mkdir -p ~/.ec2 # cp /usr/local/src/EC2/bundle/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem ~/.ec2 # cp /usr/local/src/EC2/bundle/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem ~/.ec2
- Set the environment variable to allow authentication using private key and certificate
# export EC2_PRIVATE_KEY=~/.ec2/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem # export EC2_CERT=~/.ec2/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
Setting up Java environment
As mentioned above the API tools has been build on Java, is mandatory to have installed at least Java 1.5. To be sure you have installed run the command
# rpm -qa | grep jre
if the command yields another version different or older than version 1.5, then you must run yum using bashlinux repository enabled
yum install jre
and the set the Java home environment as follows:
# export JAVA_HOME=/usr/java/jre1.6.0_05
Mac OS X users
The correct path to Java home in OS X is:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
Putting all together
To be sure you have exported all the environment variables in `~/.bashrc`, open the above file and add the following lines at the end of the file:
export JAVA_HOME=/usr/java/jre1.6.0_05 export EC2_HOME=/opt/ec2-api-tools-1.3-19403/ export EC2_PRIVATE_KEY=~/.ec2/pk-PJZHCYUQ5WGEVOJCM24PAQL734TXXK5H.pem export EC2_CERT=~/.ec2/cert-PJZHCYUQ5WGEVOJCM24PAQL734TXXK5H.pem export PATH=$PATH:$EC2_HOME/bin
Mac OS X users
The file to be used is `/etc/bashrc` and the lines to be added at the end of the file are:
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home export EC2_HOME=/opt/ec2-api-tools-1.3-19403/ export EC2_PRIVATE_KEY=~/.ec2/pk-PJZHCYUQ5WGEVOJCM24PAQL734TXXK5H.pem export EC2_CERT=~/.ec2/cert-PJZHCYUQ5WGEVOJCM24PAQL734TXXK5H.pem export PATH=$PATH:$EC2_HOME/bin