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.
2
Answers
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
I also had similar issue with aws credentials not being cleared, so I ended up deleting
RegisteredAccounts.json
file inC:Users<user>AppDataLocalAWSToolkit
.