I spend a lot of time doing bouncing between aws accounts and I couldn't find an easy way to manage the different access keys I had. After using an awesome kuberneetes tool called kubectx I was inspired to create a similar tool but for switching between different aws accounts.
- jq
- aescrypt
- Note, if on MacOS do not use
brew install aescrypt
, instead download from the link above
- Note, if on MacOS do not use
- fzf - optional for fuzzy search menus
git clone https://github.com/kadenbarlow/awsctx.git
cd awsctx
cp awsctx /usr/local/bin/awsctx
USAGE:
awsctx : list the contexts
awsctx <NAME> : switch to context <NAME>
awsctx - : switch to the previous context
awsctx -e, --export <NAME> : export context as env, e.g. source awsctx -e <name>
awsctx -c, --current : show the current context name
awsctx -s, --set <NAME> : fill ~/.aws/credentials with context variables
awsctx -n, --new : create a new aws context
awsctx -p, --password : change encryption password
awsctx <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
awsctx <NEW_NAME>=. : rename current_context to <NEW_NAME>
awsctx -d <NAME> [<NAME...>] : delete context <NAME> ('.' for current_context)
(this command won't delete the credentials in ~/.aws/credentials)
awsctx -h,--help : show this message
Awsctx uses aescrypt to store credentials securely. Although the option is provided to set credentials in the ~/.aws/credentials
file, using the command awsctx -s <NAME>
, it is recommended to source the credentials in your environment when needed to avoid storing credentials in plain text. To do this use the command source awsctx -e
and your credentials will be set to the environment variables AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
.
- Kaden Barlow - kadenbarlow
This project is licensed under the MIT License - see the LICENSE.md file for details