This is a quick and dirty tutorial on how to get set up with the AWS EC2 API.
Go to http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html and follow the instructions to get your access key. When asked, feel free to download the CSV, or simply document the Access Key and Secret Key.
Install the CLI Component
For this to work, you'll need python and pip. Once you've ensured both are installed, run this command:
pip install awscli
Generate your config and credentials file
Now that you have your credentials, go ahead and run this command:
When prompted, plug in your Access Key and Secret Access Key from the credentials you previously documented. Alternatively, if you did download the credentials, you can
cat the csv file you downloaded. For the region name, choose from the list found on this page http://docs.aws.amazon.com/general/latest/gr/rande.html
You will be searching for the section marked as Amazon API Gateway.
For the last option you're prompted for, you can specify text, table, or json for your output format preference.
Export the params required for each terminal session
export AWS_ACCESS_KEY_ID=$(ruby -ne 'print $1 if ~/.*key_id = (.*)/' < ~/.aws/credentials | rev | cut -c 1- | rev) export AWS_SECRET_ACCESS_KEY=$(ruby -ne 'print $1 if ~/.*access_key = (.*)/' < ~/.aws/credentials | rev | cut -c 1- | rev) export AWS_DEFAULT_REGION=$(ruby -ne 'print $1 if ~/region = (.*)/' < ~/.aws/config | rev | cut -c 1- | rev)
At this point you should be able to run commands like this:
aws ec2 describe-instances --output table
and get output.