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):
Removing default profile in ~/.aws/credentials
No command will work from now on without a--profile
or an AWS_PROFILE environment variableCreating 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) default
2) amplify-udemy
3) aws-lambda-deploy
4) 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! ;)
Top comments (0)