Internet Bandwidth Development: Composting the Internet for over Two Decades

CLI to Switch Amazon AWS Shell Environment Credentials

I work with many different AWS IAM Accounts and need to easily switch between these accounts. The good news is the AWS CLI tools now support a standard config file (~/.aws/config) that allows you to create profiles for multiple accounts in the one config file. You can select them when using the aws-cli with the --profile flag.

But many other tools don’t yet support the new format config file or multi-profiles. But they do support shell environment variables. So I wrote a simple ruby script that

Allows you to specify the profile name as an argument

Reads in the config file ~/.aws/config

Outputs the export statements for publishing the environment variables

You can eval the output to set the environment of your current shell session