/awsswitch

Primary LanguagePythonMIT LicenseMIT

awsswitch - AWS profile switcher

Easily switch between AWS Profiles.

PyPi PyPi

Credits

This is a pure python implementation of Johnny Opao's tool awsp.

Prerequisites

Setup your profiles using the aws cli.

aws configure --profile PROFILE_NAME

You can also leave out the --profile PROFILE_NAME param to set your default credentials.

Refer to this document for more information https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html

Setup

Install with pip

python -m pip install awsswitch

Install with pipx (recommended)

pipx install awsswitch

Shell configuration

Add the following to your .bashrc or .zshrc config:

alias awsp='awsswitch; sp="$(cat ~/.awsswitch)"; if [ -z "$sp" ]; then unset AWS_PROFILE; else export AWS_PROFILE="$sp";fi'

Or, in case kubectl ctx is used to switch cluster context:

alias awsp='awsswitch; sp="$(cat ~/.awsswitch)"; if [ -z "$sp" ]; then unset AWS_PROFILE; else export AWS_PROFILE="$sp" && k ctx $(k ctx | grep $(cat ~/.awsswitch));fi'

Usage

awsp