Mo J. Mughrabi
Mo J. Mughrabi

Reputation: 6997

working with multiple amazon ws accounts

Am currently managing several AWS accounts and doing so from command line can be annoying. Every time I have to remove the Public and Private certificate in .ec2 folder and manually replace them with another account to gain access for it.

is there a way for me to handle several certificates/accounts?

I followed the manual in here http://www.robertsosinski.com/2008/01/26/starting-amazon-ec2-with-mac-os-x/ when I first created the command-line

Upvotes: 0

Views: 143

Answers (1)

jamieb
jamieb

Reputation: 10033

Here's what I do:

Create the following script and save it as ~/bin/aws.sh:

#!/bin/bash
export EC2_REGION='us-east-1'
case "$1" in
"rbn") 
   export AWS_ACCESS_KEY='AKKDHH2HVQSHVQ32A'
   export AWS_SECRET_KEY='vizCQvkKhmMioAP/BXSe4HANGh47azvAF'
   export AWS_ACCOUNT='RBN'
   ;;
"gl") 
   export AWS_ACCESS_KEY='AKIADFGDFHHTP7ELQ'
   export AWS_SECRET_KEY='Ty+mNit235235235ETiJY/rEfxJwbQ2h+b'
   export AWS_ACCOUNT='AnotherCompanyA'
   ;;
"mcg") 
   export AWS_ACCESS_KEY='AKIAJKA2F5KRZQDBZS7A'
   export AWS_SECRET_KEY='tuQIiXgHY0B3nTEy6WaUzTsZwHUg1DiJtlAb'
   export AWS_ACCOUNT='AnotherCompanyB'
   ;;
*) 
   export AWS_ACCOUNT="No account"
   ;;
esac
echo "$AWS_ACCOUNT is active."

Then create the following alias:

alias aws='client=$1 source aws.sh $client'

Then I just execute it:

[jjbegin@bane ~]$ aws rbn
RBN is active.
[jjbegin@bane ~]$ 

Upvotes: 1

Related Questions