60

I have deleted the AWS credentials in sudo nano ~/.aws/config. But, the credentials are still in aws configure. Is there a way to reset aws configure with clear state?

John Rotenstein
  • 165,783
  • 13
  • 223
  • 298
ebertbm
  • 2,817
  • 8
  • 27
  • 43

3 Answers3

81

just remove ~/.aws/credentials along with ~/.aws/config

EDIT: Note path references user home directory and specific to each user in system.

Steven K7FAQ
  • 458
  • 1
  • 7
  • 16
pavan
  • 1,012
  • 8
  • 8
75

Do not delete the files if you have multiple profiles created as all will be lost if you delete these files! unless thats what you want :)

Go to each of the file -

 - ~/.aws/credentials
 - ~/.aws/config

and remove just the part profiles you want to delete. Eg.

~/.aws/credentials

[default]
aws_access_key_id=yourAccessKeyId
aws_secret_access_key=yourSecretAccessKey

[user2]
aws_access_key_id=yourAccessKeyId
aws_secret_access_key=yourSecretAccessKey

and

~/.aws/config

[default]
region=us-west-2
output=json

[profile user2]
region=us-east-1
output=text

Just delete entries corresponding to user2 profile if thats what you want. And you should also give a profile name to profile you configure -

aws configure --profile user2

Else it will just be [default]

More details - http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html

Aniket Thakur
  • 58,991
  • 35
  • 252
  • 267
  • Thanks @Steven for pointing it out but it was a typo as you can see the path used elsewhere corresponds to users home dir only. – Aniket Thakur Dec 28 '17 at 04:03
  • 9
    This answer is more appropriate than the one that is accepted. – Shazic Dec 19 '18 at 03:17
  • 2
    In Windows it is also helpful to note that credentials can be stored in the locations above, but can also be stored in `~\AppData\Local\AWSToolkit\RegisteredAccounts.json` as defined here: https://docs.aws.amazon.com/powershell/latest/userguide/specifying-your-aws-credentials.html#specifying-your-aws-credentials-store – Randall Borck Jun 17 '19 at 21:54
  • @RandallBorck just a note of thanks for this - developed scripts on my Mac and couldn't figure out why on Windows when I removed the profiles the scripts were still working .. ! – suitedupgeek Jun 23 '19 at 10:57
3

Here is the graphical presentation for mac user Graphical

Kirtikumar A.
  • 3,892
  • 40
  • 41