The Config Profile could not be Found AWS CLI Error [Fixed]

avatar
Borislav Hadzhiev

Last updated: Feb 26, 2024
2 min

banner

# The Config Profile could not be Found AWS CLI Error

The "config profile could not be found" error occurs when you try to run an AWS CLI command with a profile that is not configured in your AWS credentials file.

config profile not exist

The most common scenarios are:

  • the value passed to the --profile parameter has been misspelled or the profile isn't configured in the AWS credentials file.

  • the environment variable AWS_PROFILE has been set and points to a profile that isn't present in the AWS credentials file.

    When set, the AWS_PROFILE environment variable overrides the behavior of using the default AWS profile.

To solve the "the config profile could not be found" error:

  1. Check if the AWS_PROFILE environment variable is set on the machine and either unset it or set it to a profile that exists in your credentials file. To print the environment variable, use the following commands, depending on your operating system:
shell
# on Linux and macOS echo $AWS_PROFILE # on Windows with CMD (Command Prompt) echo %AWS_PROFILE% # on Windows with PowerShell echo $Env:AWS_PROFILE
  1. Run the aws configure command and set the credentials for the profile.
shell
# for the default profile aws configure # for a profile named admin aws configure --profile admin

The aws configure command writes the security credentials of the profile to:

  • the ~/.aws/credentials file on Linux and macOS.
  • the C:\Users\USERNAME\.aws\credentials on Windows.

In case you're unable to run the aws configure command and get an error, make sure to update the version of the AWS CLI you're using, or edit the credentials file directly.

The syntax of the credentials file should look as follows.

credentials
[default] aws_access_key_id=YOUR_ACCESS_KEY_ID aws_secret_access_key=YOUR_SECRET_ACCESS_KEY [admin] aws_access_key_id=YOUR_ACCESS_KEY_ID aws_secret_access_key=YOUR_SECRET_ACCESS_KEY

The region and output format settings are stored in the config file in the same directory.

This is ~/.aws/config on Linux and macOS and C:\Users\USERNAME\.aws\config on Windows.

The syntax of the config file should look similar to the following.

config
[default] region = eu-central-1 output=json [profile admin] region=eu-central-1 output=json

# 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.