Skip to content

Instantly share code, notes, and snippets.

@anderson-marques
Last active April 16, 2019 13:56
Show Gist options
  • Save anderson-marques/af5f3d63e72c526b5a0ba160144e5c63 to your computer and use it in GitHub Desktop.
Save anderson-marques/af5f3d63e72c526b5a0ba160144e5c63 to your computer and use it in GitHub Desktop.
How to manage multiples aws accounts in Terminal

How to manage multiples aws accounts easily

Configure profiles and create aliases

1. Configure the aws profiles for each credentials

  • aws configure --profile profile-a
  • aws configure --profile profile-b
  • aws configure --profile profile-c
  • aws configure --profile profile-d

2. Edit the .zshrc or .bashrc file adding

alias awsa="export AWS_DEFAULT_PROFILE=profile-a"
alias awsb="export AWS_DEFAULT_PROFILE=profile-b"
alias awsc="export AWS_DEFAULT_PROFILE=profile-c"
alias awsd="export AWS_DEFAULT_PROFILE=profile-d"
...
alias currentaws="echo $AWS_DEFAULT_PROFILE"

3. Load the .zshrc or .bashrc file

  • source ~/.zshrc or source ~/.bashrc

To change the profile

$ awsc

To print the current profile

$ currentaws
profile-c

TIP: Chose profile names and aliases that make sense for you.

Examples:

$ awsdev
$ currentaws
awsdev
$ awsqa
$ currentaws
awsqa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment