I’m often switching between different Amazon AWS accounts. So to speed things along I’ve set up some simple scripts to easily switch between accounts while at the command line
On Linux (aws_setup):
<code>#!/bin/bash export EC2_URL=https://eu-west-1.ec2.amazonaws.com export EC2_CERT=/home/john/cert-12345678901234567890123456789012.pem export EC2_PRIVATE_KEY=/home/john/pk-12345678901234567890123456789012.pem</code>
Once saved, run
chmod +x aws_setup
On Windows (aws_setup.cmd):
<code>SET EC2_URL=https://eu-west-1.ec2.amazonaws.com SET EC2_CERT=C:\Users\John\cert-12345678901234567890123456789012.pem SET EC2_PRIVATE_KEY=C:\Users\John\pk-12345678901234567890123456789012.pem</code>
Save as many files with the paths to your various AWS key pairs, and simply run the script from within a terminal before using the ec2 tools.
NOTE, when you run the scripts on Linux (and I guess Macs), add an extra dot before you run it. This will allow the environment variable to persist when the script ends.