Monday, April 25, 2011

How to use multiple AWS Accounts from the command line?

Howdy,

I've got two different apps that I am hosting (well the second one is about to go up) on Amazon EC2.

How can I work with both accounts at the command line (Mac OS X) but keep the EC2 keys & certificates separate? Do I need to change my environment variables before each ec2-* command?

Would using an alias and having it to the setting of the environment in-line work? Something like:

alias ec2-describe-instances1 = export EC2_PRIVATE_KEY=/path ; ec2-describe-instances

From stackoverflow
  • You should be able to use the following command-options in lieu of the EC2_PRIVATE_KEY (and even EC2_CERT) environment variables:

    • -K <private key>
    • -C <certificate>

    You can put these inside aliases, e.g.

    alias ec2-describe-instances1 ec2-describe-instances -K /path/to/key.pem
    
    Matt Culbreth : Perfect, that does it! I'd upmod you but I don't have the points yet.
    vladr : Congrats, you do now! ;)

0 comments:

Post a Comment