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

avatar

Borislav Hadzhiev

Wed Sep 15 20212 min read

Solving the Config Profile could not be Found Error #

The "config profile could not be found" error occurs when we try to execute an AWS CLI command with a profile that's not configured in the 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:

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:

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

Further Reading #

Add me on LinkedIn

I'm a Web Developer with TypeScript, React.js, Node.js and AWS experience.

Let's connect on LinkedIn

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee