How to Get your Default Profile with AWS CLI

avatar
Borislav Hadzhiev

Last updated: Feb 26, 2024
3 min

banner

# Get your Default Profile with AWS CLI

To see which your default AWS CLI profile is, run the aws configure list command. The command shows the name of the default profile, the profile's security credentials and the region.

shell
aws configure list

get default profile aws cli

We can see that the default profile's name is tester in the example.

The configure list command also shows where the name of the default profile is set.

In this case, the name of the default profile is set using the AWS_PROFILEenvironment variable, which has higher precedence than the settings in the credentials file.

You can find the Access Key ID and Secret Access Key of the profile in the credentials file.

shell
# on Linux and macOS ~/.aws/credentials # on Windows C:\Users\USERNAME\.aws\credentials

The region and CLI output format for the profile are stored in the config file in the same directory.

shell
# on Linux and macOS ~/.aws/config # on Windows C:\Users\USERNAME\.aws\config

When an AWS CLI command is invoked, it looks for your credentials in:

  1. Command line options - have the highest precedence and override any environment variables or configuration stored in config and credentials files.

    The command line options are: --region, --profile and --output.

  2. Environment variables on the machine - have higher precedence than the config and credentials files but get overridden by command line options.

    The environment variables are: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_OUTPUT, AWS_DEFAULT_REGION, AWS_PROFILE.

  3. The config and credentials files on your machine - have the lowest precedence - lower than environment variables and command line options.

If you are unsure where your CLI is pulling your credentials or configuration settings from, look at the Location column when calling aws configure list.

If the command's output shows that the Type is set to env and the Location is an environment variable, then it gets higher precedence than the values you've specified in your credentials file.

get default profile location

To verify whether an Environment variable is set on your machine, run the echo command that corresponds to your operating system.

shell
# Linux and macOS echo $AWS_PROFILE # on Windows with CMD echo %AWS_PROFILE% # on Windows with PowerShell echo $Env:AWS_PROFILE
You can always override the value of the default profile for one-off commands by setting the --profile parameter, e.g. aws s3 ls --profile tester.

If you want to change your default profile, check out my other article - Set your Default Profile's Name in AWS CLI .

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.