Hello to my fellow cloud engineers. In this blog we will discuss about the solution of a common AWS issue.
ERROR: An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
We get this error mostly because of 2 Reasons either we have provided wrong credentials while configuring CLI or the date/time is set incorrectly on the server.
Prerequisite
Setting up AWS CLI
# pip3 install awscli
# aws configure
Enter the access_key, secret_key and the region and you're done setting up aws cli on your machine.Test the aws configuration
# aws configure list
# aws ec2 describe-instances
I kept wondering why I am getting AuthFailure message as I was able to run the CLI commands on other system with the same credentials. Later I realized that this was happening due to mismatch of system clock time and the actual TimeZone time.
# timedatectl set-timezone 'Asia/Kolkata'
Setting the timezone didn't help as the timezone was already the same but the system time was incorrectly set.
To sync the time I tried to enable the NTP (Network Time Protocol)
# timedatectl set-ntp yes
Failed to set ntp: NTP not supported.
I have to install the NTP service as it was not present in my case.
# yum install ntp
# systemctl start ntpd
# timedatectl set-ntp yes
Able to run the aws commands through CLI successfully
# aws ec2 start-instances --instance-ids i-07ca6e35eed6c5692This is how I was able to run AWS CLI commands after resolving the AuthFailure issue. I will be glad if this has resolved your issue too, else you can reach out to me through comments/email will be happy to help.