Switch aws-cli's profile

・1 min read

If you have a multiple aws account, you should want to switch these accounts.

Aws-cli provides AWS_DEFAULT_PROFILE environment variable. When you use aws-cli, use profile in this variable.

You can easily switch profile with using the following code.

awsc () {
  export AWS_DEFAULT_PROFILE=$(grep -oE "(\[).+(\])" ~/.aws/credentials | tr -d [] | peco)
}

Please put this code to .bash_profile.

You can select a profile in your credential.

Note: Dependency

Did you find this post useful? Show some love!
DISCUSSION
Classic DEV Post from Oct 16 '18

Who is hiring? (As of October 2018)

Members of the dev.to community sharing open job opportunities at their companies.

Takeshi Kondo
Site Reliability Engineer

dev.to open source and it's magnificent

Sign Up