Working with multiple AWS account profiles could sometimes be not so pleasant experience, especially when handling different AWS named profiles for different purposes. The AWS Access Key Id does not exist in our records
is just one of the issues that could occur once in a while, so here are few solutions that might help.
Prerequisites
- AWS account
Solution #1
Verify the AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables are set and their values are correct.
echo $AWS_ACCESS_KEY_ID
echo $AWS_SECRET_ACCESS_KEY
Otherwise, first unset them.
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
Set them again.
export AWS_ACCESS_KEY_ID="<SOME_ACCESS_KEY_ID>"
export AWS_SECRET_ACCESS_KEY="<SOME_SECRET_ACCESS_KEY>"
Note(s): I’m assuming the AWS_DEFAULT_REGION
env variable is set with a correct value.
Solution #2
If you aren’t using env vars, validate the values of the AWS CLI configuration variables in the credentials file.
cat ~/.aws/credentials
The credentials file should look something like:
[default]
aws_access_key_id = SOME_ACCESS_KEY_ID
aws_secret_access_key = SOME_SECRET_ACCESS_KEY
If the AWS CLI conf vars are outdated, reconfigure them.
aws configure
Solution #3
If by any chance, you are working with temp credentials, make sure not to forget the session token var.
~/.aws/credentials
:
aws_session_token = SOME_AWS_SESSION_TOKEN
Or, as an environment variable:
export AWS_SESSION_TOKEN=<SOME_AWS_SESSION_TOKEN>
Solution #4
Last but not least, if nothing works, and the access and secret keys are existing with the correct values on AWS side.
Step 1. Remove the ~/.aws/credentials
file.
rm ~/.aws/credentials && rm ~/.aws/config
Step 2. Update or reinstall the AWS CLI.
Step 3. Create new AWS Programmatic access credentials.
Step 4. Reconfigure by running aws configure
again.
Conclusion
Managing and switching between multiple AWS accounts will be a topic for another day. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.