Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 25, 2022 01:37 pm GMT

AWS profile chooser

Super short AWS hint.

Having different AWS profiles, I do not want to pick default one just because I forgot --profile command line option.

Just looking for a way of forcing me having to choose an AWS profile before issuing any command.

My solution was (for bash only):

  1. Removing default profile in ~/.aws/credentials
    No command will work from now on without a --profile or an AWS_PROFILE environment variable

  2. Creating a one-liner alias for choosing the desired profile and setting $AWS_PROFILE environment variable.

    An alias let me reuse the same shell I'm in.

alias aws-profile-chooser='x() { select prof in $( aws configure list-profiles ) ; do  export AWS_PROFILE="$prof"; break; done }; x'

(you can see the gist here)

This command will show me available profiles, and after choosing the right one, it will set AWS_PROFILE environment variable.

$ aws-profile-choose 1) default2) amplify-udemy3) aws-lambda-deploy4) test-aws#?

From now on if I forget to choose a profile, any command will break.

Choosing and setting an AWS profile...is now a breeze! ;)


Original Link: https://dev.to/andreav/aws-profile-chooser-4ekf

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To