Vy Do
Vy Do

Reputation: 52646

AWS An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid

Due to license policy, our organization cannot use Docker Desktop for Windows. We use Docker console inside Ubuntu 22.04 WSL2. Therefore, before working with AWS ECR, I worked inside Ubuntu 22.04 . With same credentials aws_access_key_id and aws_secret_access_key , region eu-central-1:

On Windows 10, cmd

Microsoft Windows [Version 10.0.19045.3803]
(c) Microsoft Corporation. All rights reserved.

C:\Users\dnvy>aws s3 ls
2023-11-10 00:32:35 aws-landing-zone-local-cf-logs-053297099947-eu-central-1
2023-11-10 00:32:19 aws-landing-zone-local-cf-logs-053297099947-eu-west-1
2023-11-10 00:32:35 aws-landing-zone-local-elb-logs-053297098447-eu-central-1
2023-11-10 00:32:19 aws-landing-zone-local-elb-logs-053297098447-eu-west-1
2023-11-10 00:32:02 aws-landing-zone-local-s3-access-logs-099997098447-eu-central-1
2023-11-10 00:31:55 aws-landing-zone-local-s3-access-logs-053297098447-eu-west-1
2023-11-10 00:32:35 aws-landing-zone-local-waf-logs-053297099947-eu-central-1
2023-11-10 00:32:19 aws-landing-zone-local-waf-logs-053297098997-eu-west-1
2023-12-11 09:30:56 xxaxx-app-bucket
2023-12-11 08:06:33 xxxxx-xxth
2023-12-11 22:36:51 serverless-xxxxxx-dev-serverlessdeploymentbucket-xxsjpddxx3gi
2023-12-11 20:55:51 serverless-next-dev-serverlessdeploymentbucket-ljbtxxagtmsk
2023-12-13 00:43:50 www.yyas33-xxv.xxxllixx44.net

C:\Users\dnvy>

It was success.

On Ubuntu 22.04 WSL 2 (inside Windows 10) (I revised secret for security, it is not real credentials)

root@WS0419:~# aws configure
AWS Access Key ID [****************SI1X]: XXIAQY2GBF3HQNXXSI1X
AWS Secret Access Key [****************icEh]: 9Lx+HhgSxDucxZ0TvAgvr5kG2uqebx3WBYggicEh
Default region name [eu-central-1]: eu-central-1
Default output format [json]: json
root@WS0419:~# aws s3 ls

An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid.
root@WS0419:~# aws

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: the following arguments are required: command

root@WS0419:~#

It is fail.

How to make AWS CLI login success inside Ubuntu 22.04 WSL2?

Upvotes: 0

Views: 988

Answers (1)

Vy Do
Vy Do

Reputation: 52646

Go to

~/.aws/credentials

In file credentials, delete aws_session_token (key and value). then

aws configure

re-enter credentials.

Upvotes: 0

Related Questions