AWS CLI: Config, Credentials and Profiles

  • The AWS config file contains non-secret information.
  • The AWS credentials file may contain access keys in one or more profiles.
  • Use a profile to access different key pairs that may point to different accounts.

An easy way to locate the config file is through:

aws configure list

Note the output:

Your credentials file may contain multiple profiles as shown below:

[default]
aws_access_key_id=123
aws_secret_access_key=123
output=json
region=us-east-1
toolkit_artifact_guid=123

[account-x]
aws_access_key_id=456
aws_secret_access_key=456/qx0cCjnTxKJ1NpP3pyAf3nv
output=json
region=us-east-1

To switch to a different profile for your current shell session, use the export command:

export AWS_PROFILE=account-x

To see which profile is currently in use by your shell:

aws configure list

To see your available profiles:

aws configure list-profiles

Photo by Amol Tyagi on Unsplash