Switch aws-cli's profile

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 Dec 15 '17

Why we shouldn't use jQuery anymore ?

Sometimes You don't need it ! Sometimes, when building a website that doesn't ...

READ POST
Follow @belhassen07 to see more of their posts in your feed.
Takeshi Kondo
Site Reliability Engineer
Trending on dev.to
What Open-source Load Balancer Have You Used Before or Still Using Now?
#opensource #help #discuss
Alcohol and developer culture
#alcohol #health #culture #discuss
Number of followers to be shown on a profile?
#discuss #healthydebate
Personal Site or Blog Recommendation
#discuss #help #blog
Clueless developer, How to get back
#dev #discuss
What makes a successful standup?
#agile #discuss
What's your opinion on Coding Bootcamps?
#discuss #beginners #javascript #webdev
Golang, it was love at first sight.
#webdev #go #productivity #learning