https://github.com/geoffdutton/aws-profile-manager
Quickly and easily switch between AWS profiles
https://github.com/geoffdutton/aws-profile-manager
Last synced: 9 months ago
JSON representation
Quickly and easily switch between AWS profiles
- Host: GitHub
- URL: https://github.com/geoffdutton/aws-profile-manager
- Owner: geoffdutton
- License: mit
- Created: 2019-09-21T05:33:42.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T11:00:11.000Z (over 3 years ago)
- Last Synced: 2025-02-20T23:47:58.902Z (over 1 year ago)
- Language: JavaScript
- Size: 976 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-profile-manager


[](https://circleci.com/gh/geoffdutton/aws-profile-manager)
[](https://codecov.io/gh/geoffdutton/aws-profile-manager)
[](https://greenkeeper.io/)
[](https://bestpractices.coreinfrastructure.org/projects/3201)
Quickly and easily switch between AWS profiles
## Motivation
I wanted something similar to [nvm](https://github.com/nvm-sh/nvm) or [rvm](https://rvm.io/) 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:
```bash
git -c advice.detachedHead=false clone https://github.com/geoffdutton/aws-profile-manager.git --quiet -b v1.0.0 --depth=1 ~/.awsprof
cd ~/.awsprof && npm install
```
Then add this to `.bash_profile`:
```bash
export AWSPROF_INSTALL_DIR="$HOME/.awsprof"
[[ -f "$AWSPROF_INSTALL_DIR/awsprof.sh" ]] && \. "$AWSPROF_INSTALL_DIR/awsprof.sh"
```
And open a new terminal.
Then move to your project directory and save a profile:
```bash
$ cd ~/Projects/my-awesome-project
$ awsprof use
No profile set for ~/Projects/my-awesome-project
Chose a profile to use:
1) default
2) myStartup
```
Now you can see the export command to run when you're in that project directory:
```bash
$ cd ~/Projects/my-awesome-project
$ awsprof use
AWS_PROFILE=default
```
You can verify it exported the `AWS_PROFILE` environment variable:
```bash
$ awsprof
Current Env
AWS_PROFILE=default
```
Finally, you can reset it to be prompted again:
```bash
$ cd ~/Projects/my-awesome-project
$ awsprof reset
Removed stored profile for ~/Projects/my-awesome-project
```