Juggling Multiple AWS Profiles
I interact with multiple, disparate AWS profiles every day via the aws CLI tool. Here's how I ensure my aws commands end up in the right place:
- Don't set a default profile as far as the
.awsconfiguration files are concerned; instead use a set of several named profiles. My~/.aws/configand~/.aws/credentialsfiles list the same set of profiles; none are set to default. - Instead, for a particular shell instance, set your working profile via the
AWS_DEFAULT_PROFILEvariable. Make sure youexportit; i.e.export AWS_DEFAULT_PROFILE=foo. If you want to switch profiles in a given shell, just re-exportthe variable to a different profile name. - Give your shell a default profile by
export-ing this variable in your.bashrcor whatever the relevant shell init file may be1. - Ensure the current active profile2 is visible at all times in your shell so you always know what you're working with. I do this by setting the
RPROMPTin myzshdotfiles3.
