AWS EC2

From Segfault
Jump to: navigation, search

EC2 Command Line Tools

The Amazon EC2 API Tools are a commandline client interface to the Amazon EC2 web service.

Installation

wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip{,.asc}
gpg --recv-key 0x0349E66A
gpg --verify ec2-api-tools.zip.asc

unzip ec2-api-tools.zip
sudo mv ec2-api-tools-* /opt
cd /opt && ln -s ec2-api-tools-* ec2-api-tools

Setup the environment:

export EC2_HOME=/opt/ec2-api-tools
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home   # For Mac. Otherwise, /usr should do just fine.
export PATH=$PATH:$EC2_HOME/bin

We need to provide API credentials:

export AWS_ACCESS_KEY="xxx"
export AWS_SECRET_KEY="yyy"

The tools need to know where to operate on:

export EC2_URL=https://ec2.us-west-2.amazonaws.com                  # See ec2-describe-regions

Usage

$ ec2-describe-instance-status --headers
Type           InstanceId      AvailabilityZone InstanceStatus  SystemStatus  RetirementStatus [...]

INSTANCE        i-000aa123      us-west-1a      running 16      ok      ok      active  
SYSTEMSTATUS    reachability    passed  
INSTANCESTATUS  reachability    passed  

INSTANCE        i-000bb123      us-west-1b      running 16      ok      ok      active  
SYSTEMSTATUS    reachability    passed  
INSTANCESTATUS  reachability    passed

Links