aws broken AuthFailure on EC2 - amazon-web-services

My aws is suddenly throwing error everywhere since yesterday.
(on windows terminal, WSL2 ubuntu) Couple days ago terraform worked fine. So I know aws credentials are accurate but to be sure I did
aws configure --profile mohit
Access Key ID [None]: aws_access_key_id
Secret Access Key [None]: default_secret_key
Default region name [None]: us-east-1
Default output format [None]: json
and executed
aws ec2 --profile mohit describe-instances --region ap-south-1
IAM user has Administrator access.So that rules out permission issues.
Also I tried Bunch of different regions, none worked.
An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
This error is consistent.
AWS says time might be out of sync with amazon.
I tried the solution and
ntpdate[172]: the NTP socket is in use, exiting this error popped.
Also
sudo service ntp stop
>> ntp: unrecognized service
and
Fatal error : adjtimex(0x8001) failed : Function not implemented on trying to do chronyd on WSL2 ubuntu.
How do I fix this?
UPDATE :
I checked my BIOS and clock was off by 5 min there as well (I would love to know the reason) So I manually set it to time.gov UTC.
Problem Solved, but Reason is still unknown!

Related

Security token problem when creating a container service using docker and AWS

I was following this guide:
https://aws.amazon.com/getting-started/hands-on/serve-a-flask-app/
I installed everything and got to this section 4:
$ aws lightsail create-container-service --service-name flask-service \ --power small --scale 1
I got an error, but removed the slash:
$ aws lightsail create-container-service --service-name flask-service --power small --scale 1
Then I got:
You must specify a region. You can also configure your region by running "aws configure".
PS C:\Data\programming\lightsail-containers-flask> aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:
PS C:\Data\programming\lightsail-containers-flask> aws lightsail create-container-service --service-name flask-service --power small --scale 1
You must specify a region. You can also configure your region by running "aws configure".`
I then ran configure:
PS C:\Data\programming\lightsail-containers-flask> $Env:AWS_ACCESS_KEY_ID="HKDSFJKSJDHEXAMPLE"
PS C:\Data\programming\lightsail-containers-flask> $Env:AWS_SECRET_ACCESS_KEY="HJLhjk678HJK7/ljknioi/hjkytEXAMPLE"
PS C:\Data\programming\lightsail-containers-flask> $Env:AWS_DEFAULT_REGION="us-west-2"`
then running again:
$ aws lightsail create-container-service --service-name flask-service --power small --scale 1``
gives me:
An error occurred (UnrecognizedClientException) when calling the CreateContainerService operation: The security token included in the request is invalid.`
Is there any way for me to solve this or create a docker container service to upload a flask app? I have searched around and can't find an answer, although I'm sure there is one. This is my first time using stack overflow so my apologies for any errors is etiquette or formatting.

Access Denied error while trying to use AWS CLI commands

I have a user in AWS having Full admin access but still when I try to describe my EC2 instances or List S3 buckets, I get an Access denied error message - examples below. Any help will be greatly appreciated.
aws s3 ls
An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied
aws ec2 describe-instances --region eu-west-2
An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation: You are not authorized to perform this operation.
From the command prompt or Linux shell type "aws configure". Verify that the credentials and default region are correct (the last four characters will be displayed). I had the same problem today and I forgot to configure my access keys on a new machine.

Invalid IPv6 URL while running commands using AWS CLI

configured AWS Cli on Linux system.
While running any command like "aws ec2 describe-instances" it is showing error "Invalid IPv6 URL"
Ran into the same error.
Running this command fixed the error for me:
export AWS_DEFAULT_REGION=us-east-1
You might also try specifying the region when running any command:
aws s3 ls --region us-east-1
Hope this helps!
or run aws configure and enter valid region for default region name
I ran into this issue due to region being wrongly typed. When you run aws configure during initial setup, if you try to delete a mistaken entry, it will end up having invalid characters in the region name.
Hopefully, running aws configure again will resolve your issue.

aws ec2 get-console-output prints nothing to the screen

I am creating an aws ec2 instance using this tutorial, and I can't find any information on troubleshooting my issue, or any evidence that anyone else has even experienced this!
I used an IAM user with admin permissions to set up an ec2 instance, and when I run
$> aws ec2 get-console-output --instance-id <my-ec2-id>
a blank line is output, followed by
'Output'
and nothing else!
According to the tutorial, this command would enable me to see the remote RSA fingerprint to verify I'm making the right connection.
I can log into my ec2 instance just fine (though I suppose without the previous step there's no way to be absolutely sure).
Additionally, the IAM user I'm working with is not my CLI's default user, and I set up a profile to handle it. But if I try
$> aws ec2 get-console-output --profile <user-profile> --instance-id <my-ec2-id>
I still get the same results as before. The maddening thing is that I have solved this problem before, but I can't remember how.
Certain AWS CLI operations may not explicitly state if the credentials are invalid or if users are lacking the roles/permissions to access the resources defined. In this case, it is likely due to the Access Credentials being invalid - and you can verify this with a describe-instances or similar command.
In older versions of the CLI (~1.7), in order to easier debug this, you can use the --debug argument, such as:
> aws ec2 get-console-output --instance-id i-<id> --debug
<Errors><Error><Code>InvalidInstanceID.NotFound</Code><Message>The instance ID 'i-e7bffa43' does not exist</Message></Error></Errors>
In newer versions of the CLI (1.9) this particular argument gives a bit more detail in its error:
> aws ec2 get-console-output --instance-id i-<id>
A client error (InvalidInstanceID.NotFound) occurred when calling the GetConsoleOutput operation: The instance ID 'i-<id>' does not exist

Running AWS CLI commands as ec2-user

I'm trying to use the AWS CLi for the first time, and I am doing it through putty by SSHing to the ec2 instance.
I want to run a command like "aws ec2 authorize-security-group-ingress [options]"
But I get the following error: "A client error (UnauthorizedOperation) occurred when calling the AuthorizeSecurityGroupIngress operation: You are not authorized to perform this operation."
I believe that this is related to IAM user credentials. I have found out where to create IAM users, however I still don't understand how this helps me to execute this command when I'm logged into the server as ec2-user or root, or run the command through CRON.
I have done a fair amount of reading regarding the access controls on AWS in their documentation, but I seem to be missing something.
How can I allow the command to be executed from within the AWS instance?
The missing information I was looking for is the command: aws configure
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json