Working with multiple AWS account profiles could sometimes be not so pleasent 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.
- AWS Account
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: I’m assuming the
AWS_DEFAULT_REGION env variable is set with a correct value.
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
If by any chance, you are working with temp credentials, make sure not to forget the session token var.
aws_session_token = SOME_AWS_SESSION_TOKEN
Or, as environment variable:
$ export AWS_SESSION_TOKEN=<SOME_AWS_SESSION_TOKEN>
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
$ 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.
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.