0 votes
1 view
in AWS by (19.2k points)

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

1 Answer

0 votes
by (44.6k points)

You can use these following command-options using EC2_PRIVATE_KEY (and even EC2_CERT) environment variables:

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

After that, you can use them inside aliases, e.g.

alias ec2-describe-instances1 ec2-describe-instances -K /path/to/yourkey.pem

There is also a straightforward way to do this:

$ aws configure --profile myaccount1

$ aws configure --profile myaccount2

You can then switch between the accounts by passing the profile on the command.

$ aws dynamodb list-tables --profile myaccount1

$ aws s3 ls --profile myaccount2

Also, you can set your primary account by mentioning default in it

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...