How to Clear your AWS CLI Credentials


Borislav Hadzhiev

Fri Sep 24 20212 min read

Clear your AWS CLI Credentials #

In order to clear your AWS CLI Credentials you have to:

  1. Locate the credentials and config files. The path depends on your operating system:
# on Linux and macOS ~/.aws/credentials ~/.aws/config # on Windows C:\Users\USERNAME\.aws\credentials C:\Users\USERNAME\.aws\config
  1. Open the files in a text editor and remove the unnecessary profiles. A profile's configuration is split between the credentials and config files in the following way:
[default] aws_access_key_id=YOUR_ACCESS_KEY_ID aws_secret_access_key=YOUR_SECRET_ACCESS_KEY [admin] aws_access_key_id=YOUR_ACCESS_KEY_ID aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
[default] region = us-east-1 output=json [profile admin] region=us-east-1 output=json
  1. Once the unnecessary profiles are deleted from your credentials and config files, save the changes and the profile is removed from your machine
If your credentials and config files contain a single profile, you can just delete the files to clear your AWS CLI credentials. The next time you run the aws configure command the AWS CLI will automatically re-create them for you.

Be sure to delete any configuration referencing a profile from both files - credentials and config.

The next time you need to add your AWS CLI credentials, you can run the aws configure command to either add a profile to the list, or re-create the config and credentials files on your machine:

# For the Default profile aws configure # For a profile named admin aws configure --profile admin

The access and secret access keys will again be stored in the credentials file, whereas the region and output format will be in the config file.

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee