How to Configure AWS CLI

The AWS CLI uses configuration settings and credentials stored locally in the folder .aws, in files named config and credentials.

The settings in the files are divided into profiles, identified with a profile name in brackets. For example, consider this samlpe .aws/config file:

[default]
region = us-east-2

This indicates that the region for the default profile is us-east-2.

Creating the default settings

To set up the default config and credentials file, run the aws configure command. This will prompt you to enter your AWS Access Key Id, your AWS Secret Access Key, a default region and a default output format.

Profiles

The AWS CLI enables settings to be grouped into profiles, so that you can use multiple accounts or credentials. To create a new profile, run aws configure --profile my-profile. You will again be prompted for the config settings and credentials to be used for this profile.

To specify a profile when running an AWS CLI command, include --profile my-profile in the command. For example, the following command will list all S3 buckets in the account identified by the default profile:

aws s3api list-buckets 

To view the S3 buckets in my-profile, adjust the command as below:

aws --profile my-profile s3api list-buckets 

Resources

AWS Access Keys

For information about how to create and manage AWS access keys see: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html

AWS CLI Commands

For information about available AWS CLI commends see: https://docs.aws.amazon.com/cli/latest/reference/