How do I set the name of the default profile in AWS CLI?

I have multiple profiles too, I use AWS_DEFAULT_PROFILE to switch back and forth. However, I've named each profile something descriptive, like aws-engineering and aws-production. Then, I can use set AWS_DEFAULT_PROFILE=aws-engineering and I'm good to go.

I have no DEFAULT profile specified in my ~/.aws/config, this was intentional so that I always explicitly have to choose which environment I'm working on.


Setting the AWS_DEFAULT_PROFILE environment variable at the command line should specify the profile.

See: Can I specify a default AWS configuration profile?

For example:

Linux, macOS, or Unix

export AWS_DEFAULT_PROFILE=user2

Note: To unset, run: unset AWS_DEFAULT_PROFILE.

To make the change persistent, add above line into your ~/.bashrc user's file.

Note: You can also use AWS_PROFILE. See: Named Profiles.

Windows

set AWS_DEFAULT_PROFILE=user2

Source: User Guide » Configuring the AWS CLI » Named Profiles.

See also: A New and Standardized Way to Manage Credentials in the AWS SDKs.


You just switch to the profile you want (for ex: in Linux use: export AWS_DEFAULT_PROFILE=MyProfile) and then switch back to the default profile using export AWS_DEFAULT_PROFILE=default. 'default' is the profile name given to your first profile when you create it.