2

Image

I created a user in IAM service. and then I entered AWS configure command and entered user access key and secret key and region correctly. but the default account is not changing according to entered details. after that, I deleted .aws/credentials and aws/config. Also I reinstalled AWS cli. Without adding any user, still there can be seen default profile with access key, secret key and region.

I entered StackOverflow answer example access keys and secretkeys accidentally using setx keyword.

How to solve this problem?

When I give aws lambda list-functions, I get this error:

An error occurred (UnrecognizedClientException) when calling the ListFunctions operation: The security token included in the request is invalid.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Do you just want to enter different credentials? Just run the `aws configure` command again. Anything you enter will overwrite the values. – John Rotenstein Apr 20 '23 at 05:38
  • but it doesn't overwrite. I tried many times it – amila upendra Apr 20 '23 at 05:40
  • 2
    Ah! You used `setx`? This create **Environment Variables**, which will override the settings in the `.aws/credentials` file. You should remove the Environment Variables. [How to Clear Environment Variables in Windows](https://www.alphr.com/clear-environment-variables-windows/) – John Rotenstein Apr 20 '23 at 05:42
  • I would recommend you to use AWS CLI --profile instead of using default profile – Hùng Nguyễn Apr 20 '23 at 09:26

2 Answers2

1

It appears that the AWS credentials set via Environment Variables are earlier in the 'credentials provider chain' than the credentials defined in local configuration files.

To use the local configuration files, you will need to 'unset' the Environment Variables.

See: How to Clear Environment Variables in Windows

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
0

I also had similar issue with aws credentials not being cleared, so I ended up deleting RegisteredAccounts.json file in C:\Users\<user>\AppData\Local\AWSToolkit.

Bomberlt
  • 259
  • 1
  • 8
  • 21