9

I was able to install CLI on windows 16 AWS instance. when I try "aws ec2 describe-instances" CLI command, I get the following error

CLI command "describe-instances" throw error "An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials"

In .aws\config file I have following content:

[default]
   region = us-west-2

How can authorization fail when it took my access key id and secret access key without any issue.

AuthFailure

8 Answers 8

16

Verify if your datetime is sync ok.

use: ntpdate ntp.server

7
  • Assuming you are answering the question (How can authorization fail when it took my access key id and secret access key without any issue.), please provide more details, so this context is clear. As it is written now, it's hard to tell whether you are answering the question at all. See: stackoverflow.com/help/how-to-answer
    – Elijan9
    Mar 22, 2020 at 9:34
  • @Elijan9 my date was off by 20min and it blocked the auth to aws
    – Skullone
    May 6, 2021 at 15:04
  • it worked for me..my mac time was ahead by 7 mins. thx Oct 14, 2022 at 5:39
  • this worked for me, my laptop's clock was around 6 minutes in the future
    – Jorge V.
    Jan 7, 2023 at 0:11
  • For Windows users: sometimes it can't automatically sync the time. Old issue. Go to Date & time, click Sync Now, and try to access AWS again. Mar 11, 2023 at 11:51
9

I deleted my two configuration files from .aws directory and re-ran "aws config" That fixed the problem for me.

My Steps:

  • Go to your .aws directory under Users e.g. "c:\Users\Joe\.aws"
  • Two files: configure and credential. Delete both files
  • Rerun configure: "aws configure"

Note when you run aws configure you will need the AWS Access and Secret Key. If you don't have them you can just create another. Steps:

  • Goto "My Security Credentials" Under you Account Name in AWS Console.
  • Expand Access Key panel.
  • Create New Access Key.
0
3

When you first ran aws configure, it just populated the local credentials in %UserProfile%\.aws\credentials; it didn't validate them with AWS.

(aws-cli doesn't know what rights your user has until it tries to do an operation -- all of the access control happens on AWS's end. It just tries to do what you ask, and tells you if it doesn't have access, like you saw.)

That said, if you're running the CLI from an AWS instance, you might want to consider applying a role to that instance, so you don't have to store your keys on the instance.

0
1

My Access and Security keys are correct. My server time was good. I got error while using Ap-south-1 region. After I changed my region to us-west-2, it worked without any problem.

1
  • Changing regions fixed it for me too.
    – Rob
    May 23, 2023 at 10:39
1

For me, I had to go to the Amazon cache folder:

C:\Users\JohnDoe\.aws

Then edit the "credentials" file with Notepad++ and add the "aws_session_token" like to the file.

So my file looks like this:

[default]
aws_access_key_id=A_KEY
aws_secret_access_key=A_SECRET_ACCESS_KEY
aws_session_token=A_SESSION_TOKEN
0

I tried setting that too on my windows environment. didn't work and getting error above.

so I tried setting my environment

SET AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY

SET AWS_SECRET_ACCESS_KEY=***YOUR_SECRET_ACCESS_KEY*

and then tried running command like "aws ec2 describe-instance"

0
0

I tried many things. Finally, just uninstalling and installing again (not repairing) did the trick. Just make sure to save a copy of your credentials (key and key ID) to use later when calling aws configure.

0

If you encounter this problem using AWS CLI on WSL2 (Windows Subsystem for Linux) where NTP service cannot be started:

Condition: start condition failed at ...
           └─ ConditionVirtualization=!container was not met

simply use:

sudo hwclock -s

Details in this SO question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.