Fri Sep 24 2021·1 min read
Photo by Erik Mclean
In order to set the name for the default AWS CLI profile, set the
AWS_PROFILE environment variable to the name of the profile stored in your
config files, e.g.
admin for a named profile, or
for the default profile.
For example, if my AWS
credentials file consists of the
[default] aws_access_key_id=MY_ACCESS_KEY_ID aws_secret_access_key=MY_SECRET_ACCESS_KEY [admin] aws_access_key_id=MY_OTHER_ACCESS_KEY_ID aws_secret_access_key=MY_OTHER_SECRET_ACCESS_KEY
And I set the
AWS_PROFILE environment variable to
admin, then any AWS CLI
command I run, without explicitly setting the
--profile parameter, will be
executed with the
admin profile's credentials.
How you set the
AWS_PROFILE environment variable depends on your operating
# Linux and MacOS export AWS_PROFILE=admin # Windows Command Prompt setx AWS_PROFILE admin # PowerShell $Env:AWS_PROFILE="admin"
To make the environment variable persist on
MacOS, add the
export AWS_PROFILE=your_profile line to your shell's startup script, e.g.
AWS_PROFILE environment variable is set, it has higher precedence and
overrides the default profile you've stored in your
AWS_PROFILEenvironment variable is to pass the
--profileparameter to the specific AWS CLI command.
I'll send you 1 email a week with links to all of the articles I've written that week