Amazon Web Services Tips

  


[an error occurred while processing this directive]

No Title

[an error occurred while processing this directive]

Reference: Cisco: Internetworking Basics

Contents

Introduction

This short guide presents an example of the steps on how to install the Amazon API Tools and the Amazon AMI Tools on the Linux (CentOS 6) platform.

The Amazon API Tools and the Amazon AMI Tools are packages of command-line scripts to the AWS web service used to manage and bundle instances. Although there are many other Developer Tools provided by Amazon and the AWS development community to help developers create and manage applications built on AWS, these two are the most commonly used to manage EC2 instances.

Install Amazon EC2 Tools (Linux)

Use the following steps to install the Amazon API Tools and the Amazon AMI Tools on the Linux platform.

  1. Shell Login Script

    Add the following environment variables to your shell login script (i.e. /root/.bashrc). Make any necessary changes for your specific environment by replacing AWS_ACCOUNT_NUMBER, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY with your AWS account number and security credentials. Make certain to remove the < and > characters when providing your values.


    # cp /root/.bashrc /root/.bashrc.backup # vi /root/.bashrc export EC2_BASE=/opt/ec2 export EC2_HOME=$EC2_BASE/tools export EC2_PRIVATE_KEY=$EC2_BASE/certificates/ec2-pk.pem export EC2_CERT=$EC2_BASE/certificates/ec2-cert.pem export EC2_URL=https://ec2.amazonaws.com export AWS_ACCOUNT_NUMBER=<999999999999> export AWS_ACCESS_KEY_ID=<your_access_key_id> export AWS_SECRET_ACCESS_KEY=<your_secret_access_key> export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$EC2_HOME/bin export JAVA_HOME=/usr # source ~/.bashrc

  2. Install Java

    The EC2 API Tools and Amazon EC2 AMI Tools are Java based. If you don't already have a version of Java installed, do so now.


    # yum -y install java-1.6.0-openjdk

    The JAVA_HOME environment variable should be set to the appropriate home directory in your shell login script (i.e. /root/.bashrc) which was handled in the previous step. Verify the JAVA_HOME environment variable is set for the current shell and confirm that Java is installed correctly.


    # echo $JAVA_HOME /usr # java -version java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.3) (rhel-1.48.1.11.3.el6_2-x86_64) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

  3. Install the Amazon EC2 Tools

    Download the Amazon EC2 API Tools.


    # mkdir -p $EC2_HOME # curl -o /tmp/ec2-api-tools.zip http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip # unzip /tmp/ec2-api-tools.zip -d /tmp # cp -r /tmp/ec2-api-tools-*/* $EC2_HOME

    Download the Amazon EC2 AMI Tools to the EC2 image.


    # curl -o /tmp/ec2-ami-tools.zip http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip # unzip /tmp/ec2-ami-tools.zip -d /tmp # cp -rf /tmp/ec2-ami-tools-*/* $EC2_HOME

  4. EC2 Private Certificate Key File and EC2 Certificate File

    Copy your X.509 Certificate (private key file and certificate file) to appropriate directory. For the purpose of this example, I will be renaming my private key file from pk-2L7LZYRTNEAC4KGZMPPZWAOZ4KYCTCA4.pem to ec2-pk.pem and my certificate file from cert-2L7LZYRTNEAC4KGZMPPZWAOZ4KYCTCA4.pem to ec2-cert.pem.


    # mkdir -p $EC2_BASE/certificates # cp pk-2L7LZYRTNEAC4KGZMPPZWAOZ4KYCTCA4.pem $EC2_BASE/certificates/ec2-pk.pem # cp cert-2L7LZYRTNEAC4KGZMPPZWAOZ4KYCTCA4.pem $EC2_BASE/certificates/ec2-cert.pem

  5. Verify Amazon EC2 Tools

    Verify that the Amazon EC2 Tools have been installed correctly.

    Test the ec2-describe-regions script which is found in the EC2 API Tools to list the regions you have access to.


    # ec2-describe-regions | sort REGION ap-northeast-1 ec2.ap-northeast-1.amazonaws.com REGION ap-southeast-1 ec2.ap-southeast-1.amazonaws.com REGION eu-west-1 ec2.eu-west-1.amazonaws.com REGION sa-east-1 ec2.sa-east-1.amazonaws.com REGION us-east-1 ec2.us-east-1.amazonaws.com REGION us-west-1 ec2.us-west-1.amazonaws.com REGION us-west-2 ec2.us-west-2.amazonaws.com

     

    If you receive the following error message running any of the EC2 tools, make certain that the date and time are set correctly.

    # ec2-describe-regions
    Client.InvalidSecurity: Request has expired
          
    # date
    Thu Jun  7 02:53:27 EDT 2012
    
    /* The above date is 17 days off */
    
    # date -s "24 JUN 2012 13:36:00"
    Sun Jun 24 13:36:00 EDT 2012

About the Author

Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX / Linux server environment. Jeff's other interests include mathematical encryption theory, tutoring advanced mathematics, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 20 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science and Mathematics.



Copyright (c) 1998-2017 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Friday, 11-Apr-2014 18:51:03 EDT
Page Count: 511