Why and What

To implement some functionalities that Amazons EC2 Cloud provides, you have to interface with their command-line API tools. Likely, the product is too young to have the equivalent functionality built-in to their GUI management console yet. For now, we do it this way, and its a little complex.


I setup the environment below on a mac. The setup steps are slightly different on a mac, than from what is explained on the amazon docs, which is angled for straight linux/unix. Mostly the difference is in how macs do environment variables and paths. Please adjust accordingly.

Java Setup

  • set JAVA_HOME
    • nano ~/.bash_profile
      export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
  • restart the shell now - close it and log back in
  • Verify it works
    • $JAVA_HOME/bin/java -version
      java version "1.6.0_17"
      Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-10M3025)
      Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)

X.509 Credentials

You can use existing ones on the existing amazon account (if you have the private key from whoever originally made it), OR You can create your own new ones. Here I made new ones, according to the guide linked above.

  • AWS UI Sign in > Accounts > Security credentials > X.509 tab > Create New
  • Put files in appropriate locations
    • mkdir ~/.ec2
      mv ~/Downloads/pk-KFGXD35XEHEO5OUO3IE2OETS5UMPA3JA.pem ~/.ec2/
      mv ~/Downloads/cert-KFGXD35XEHEO5OUO3IE2OETS5UMPA3JA.pem ~/.ec2/

Setup EC2 API tools

These are used to run the command line calls that we will use later.

  • Find at EC2 API Tools
  • Download and unzip as per docs; I unzipped to ~/ec2-api-tools-1.3-46266
  • Tell the tools where they live
    • nano ~/.bash_profile
      export EC2_HOME=~/ec2-api-tools-1.3-46266
      export PATH=$PATH:$EC2_HOME/bin
      export EC2_PRIVATE_KEY=~/.ec2/pk-KFGXD35XEHEO5OUO3IE2OETS5UMPA3JA.pem
      export EC2_CERT=~/.ec2/cert-KFGXD35XEHEO5OUO3IE2OETS5UMPA3JA.pem
  • restart the shell now - close it and log back in

Check to see if working

  • # check to see that variables are there
    # check to see that command and connection to AWS is working
    # test create and stop an instance
    ec2-run-instances ami-b232d0db --key awsnickkey
    ec2-describe-instances i-dd2142b6
    ec2-stop-instances i-dd2142b6
    ec2-terminate-instances i-dd2142b6
technology/cloud/setup_ec2_api_tools.txt · Last modified: 06.30.2010 17:21 by nyeates1
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki