Difference between revisions of "Aws-build"

From Bashlinux
Jump to: navigation, search
Line 4: Line 4:
 
== Installing AMI Tools ==
 
== Installing AMI Tools ==
   
1. Download the AMI Tools RPM available Amazon:
+
# Download the AMI Tools RPM available Amazon:
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 10: Line 10:
 
</nowiki></pre>
 
</nowiki></pre>
   
1. Install the downloaded RPM:
+
# Install the downloaded RPM:
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 18: Line 18:
 
</nowiki></pre>
 
</nowiki></pre>
   
1. In order to isolate the resulting files create a new folder and put the image there:
+
# In order to isolate the resulting files create a new folder and put the image there:
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 32: Line 32:
 
</nowiki></pre>
 
</nowiki></pre>
   
It will splits and encrypts the image into manageable parts for upload.
+
It will splits and encrypts the image into manageable parts for upload.
''-i'' refers to the name of the image.
+
* ''-i'' refers to the name of the image.
''-k'' refers to the ''Private Key'' file.
+
* ''-k'' refers to the ''Private Key'' file.
''-c'' refers to the ''Certificate'' file.
+
* ''-c'' refers to the ''Certificate'' file.
''-u'' refers to the ''user ID'' that is the ''AWS account'' ID without dashes.
+
* ''-u'' refers to the ''user ID'' that is the ''AWS account'' ID without dashes.
1. Upload the bundle image
+
* Upload the bundle image
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 51: Line 51:
   
 
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.
 
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.
1. Download API tools from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88
+
# Download API tools from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88
1. Decompress the file and place the content under /opt
+
# Decompress the file and place the content under /opt
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 59: Line 59:
 
</nowiki></pre>
 
</nowiki></pre>
   
1. Set the environment variable for EC2 API tools
+
# Set the environment variable for EC2 API tools
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 65: Line 65:
 
</nowiki></pre>
 
</nowiki></pre>
   
<!-- # Add the _bin_ directory of API tools to the system path -->
+
# Add the _bin_ directory of API tools to the system path
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 75: Line 75:
   
 
=== Setting up Private Key and Certificate for authentication ===
 
=== Setting up Private Key and Certificate for authentication ===
1. Place private key and certification into a secure and accessible location
+
# Place private key and certification into a secure and accessible location
   
 
<pre><nowiki>
 
<pre><nowiki>
Line 83: Line 83:
 
</nowiki></pre>
 
</nowiki></pre>
   
1. Set the environment variable to allow authentication using private key and certificate
+
# Set the environment variable to allow authentication using private key and certificate
   
 
<pre><nowiki>
 
<pre><nowiki>

Revision as of 20:55, 14 February 2011

Building an AMI

Installing AMI Tools

  1. Download the AMI Tools RPM available Amazon:
wget https://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
  1. Install the downloaded RPM:
# rpm -ivh ec2-ami-tools.noarch.rpm
Preparing...                ########################################### [100%]
   1:ec2-ami-tools          ########################################### [100%]
  1. 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

1. 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.

  1. Download API tools from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88
  2. Decompress the file and place the content under /opt
# cd /opt
# unzip ec2-api-tools.zip
  1. Set the environment variable for EC2 API tools
# export EC2_HOME=/opt/ec2-api-tools-1.3-19403
  1. 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

  1. 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
  1. 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


#!wiki info
'''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


#!wiki info

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`