Aws-build: Difference between revisions

From Bashlinux
Jump to navigationJump to search
Content deleted Content added
Manpaz (talk | contribs)
No edit summary
Manpaz (talk | contribs)
Redirected page to Building an AMI
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
#REDIRECT [[Building an AMI]]
__NOTOC__
= Building an AMI =

== Installing AMI Tools ==

# Download the AMI Tools RPM available Amazon:

<pre><nowiki>
wget https://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
</nowiki></pre>

# Install the downloaded RPM:

<pre><nowiki>
# rpm -ivh ec2-ami-tools.noarch.rpm
Preparing... ########################################### [100%]
1:ec2-ami-tools ########################################### [100%]
</nowiki></pre>

# In order to isolate the resulting files create a new folder and put the image there:

<pre><nowiki>
# 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
</nowiki></pre>

1. Bundle the image

<pre><nowiki>
# ec2-bundle-image -i bashlinux-general-server.fs -k pk-ABCDEFGHI1ABCDEFG2ABC3ABCD45ABC.pem -c cert-ABCDEFGHI1ABCDEFG2ABC3ABCD45ABC.pem -u 123456789012
</nowiki></pre>

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

<pre><nowiki>
# ec2-upload-bundle -b bashlinux -m /tmp/bashlinux-general-server.fs.manifest.xml -a <access_key> -s <secret_key>
</nowiki></pre>

''-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

<pre><nowiki>
# cd /opt
# unzip ec2-api-tools.zip
</nowiki></pre>

# Set the environment variable for EC2 API tools

<pre><nowiki>
# export EC2_HOME=/opt/ec2-api-tools-1.3-19403
</nowiki></pre>

# Add the _bin_ directory of API tools to the system path

<pre><nowiki>
# export PATH=$PATH:$EC2_HOME/bin
</nowiki></pre>


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

<pre><nowiki>
# mkdir -p ~/.ec2
# cp /usr/local/src/EC2/bundle/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem ~/.ec2
# cp /usr/local/src/EC2/bundle/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem ~/.ec2
</nowiki></pre>

# Set the environment variable to allow authentication using private key and certificate

<pre><nowiki>
# export EC2_PRIVATE_KEY=~/.ec2/pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
# export EC2_CERT=~/.ec2/cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem
</nowiki></pre>


=== 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

<pre><nowiki>
# rpm -qa | grep jre
</nowiki></pre>

if the command yields another version different or older than version 1.5, then you must run yum using bashlinux repository enabled

<pre><nowiki>
yum install jre
</nowiki></pre>

and the set the Java home environment as follows:

<pre><nowiki>
# export JAVA_HOME=/usr/java/jre1.6.0_05
</nowiki></pre>


<pre><nowiki>#!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`
</nowiki></pre>


=== 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:

<pre><nowiki>
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
</nowiki></pre>



<pre><nowiki>#!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`
</nowiki></pre>

Latest revision as of 22:59, 9 June 2015

Redirect to: