aws-profile-manager
Quickly and easily switch between AWS profiles
Motivation
I wanted something similar to nvm or rvm to manage and set my AWS_PROFILE
environment variouable based on the directory I'm in.
Overview
The first proof of concept uses a centralized JSON file to keep track of what profiles to use for which directories in .aws-profile-manager/config.json
rather than relying on some sort of dot RC file per project.
Currently, this doesn't actually export any environment variables, as I'm still trying to figure out the best way to do that.
Important note: this profile manager doesn't modify your ~/.aws/credentials
file, and only parses the aws creds file locally to present options to the user.
Usage
First thing, install it globally:
git -c advice.detachedHead=false clone https://github.com/geoffdutton/aws-profile-manager.git --quiet -b v1.0.0 --depth=1 ~/.awsprofcd ~/.awsprof && npm install
Then add this to .bash_profile
:
export AWSPROF_INSTALL_DIR="$HOME/.awsprof" && \. "$AWSPROF_INSTALL_DIR/awsprof.sh"
And open a new terminal.
Then move to your project directory and save a profile:
$ cd ~/Projects/my-awesome-project$ awsprof useNo profile set
Now you can see the export command to run when you're in that project directory:
$ cd ~/Projects/my-awesome-project$ awsprof useAWS_PROFILE=default
You can verify it exported the AWS_PROFILE
environment variable:
$ awsprofCurrent EnvAWS_PROFILE=default
Finally, you can reset it to be prompted again:
$ cd ~/Projects/my-awesome-project$ awsprof resetRemoved stored profile