Solve - the Config Profile could not be Found AWS CLI Error

avatar

Borislav Hadzhiev

Last updated: Jul 25, 2022

banner

Check out my new book

Solving the Config Profile could not be Found 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 is not configured in the AWS credentials file

  • the environment variable AWS_PROFILE has been set and points to a profile that is not 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
# Linux and macOS echo $AWS_PROFILE # on Windows with CMD 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 in the ~/.aws/credentials file on Linux and macOS and in 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 like the following.

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. That is ~/.aws/config on Linux and macOS and C:\Users\USERNAME\.aws\config on Windows.

The syntax of the config file should look like the following.

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

Further Reading #

Use the search field on my Home Page to filter through my more than 3,000 articles.