AWS CLI

AWS CLI

AWS Command Line Interface
AWS Command Line Interface Documentation

Installing, updating, and uninstalling the AWS CLI version 2 on macOS

Installing, updating, and uninstalling the AWS CLI version 2 on macOS


Prerequisite

Download Homebrew


Check if you have a previous AWS CLI version

Shell
1
2
which aws
aws --version


Install and update the AWS CLI version 2 using Homebrew

Shell
1
brew install awscli


Verify the installation

Shell
1
2
which aws
aws --version


AWS CLI Configuration

Configure

configure


Configuration basics

Configuring the AWS CLI

Quick configuration with aws configure

For general use, the aws configure command is the fastest way to set up your AWS CLI installation. When you enter this command, the AWS CLI prompts you for four pieces of information:

Make sure you have all of the above information before you start the next steps!

Run aws configure then input your information like this:

Shell
1
2
3
4
5
6
aws configure

AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json


Profiles (for additional users)

Profiles

A collection of settings is called a profile. By default, the AWS CLI uses the default profile. You can create and use additional named profiles with varying credentials and settings by specifying the --profile option and assigning a name.

The following example creates a profile named Zacks.

Shell
1
2
3
4
5
6
aws configure --profile Zacks

AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE
AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text

You can then specify a --profile profilename and use the credentials and settings stored under that name.

Shell
1
aws s3 ls --profile Zacks

To update these settings, run aws configure again (with or without the --profile parameter, depending on which profile you want to update) and enter new values as appropriate. The next sections contain more information about the files that aws configure creates, additional settings, and named profiles.

For more information on named profiles, see Named profiles.


Creating access keys for the root user

AWS account root user

Choose your account name in the navigation bar, and then choose My Security Credentials.
If you see a warning about accessing the security credentials for your AWS account, choose Continue to Security Credentials.


Expand the Access keys (access key ID and secret access key) section.
Choose Create New Access Key. If this feature is disabled, then you must delete one of the existing access keys before you can create a new key. For more information, see IAM Entity Object Limits in the IAM User Guide.


A warning explains that you have only this one opportunity to view or download the secret access key. It cannot be retrieved later.

  • If you choose Show Access Key, you can copy the access key ID and secret key from your browser window and paste it somewhere else.
  • If you choose Download Key File, you receive a file named rootkey.csv that contains the access key ID and the secret key. Save the file somewhere safe.


When you no longer use the access key we recommend that you delete it, or at least mark it inactive by choosing Make Inactive so that it cannot be misused.


Configuration and credential file settings

Configuration and credential file settings

aws configure set

You can set any credentials or configuration settings using aws configure set. Specify the profile that you want to view or modify with the --profile setting.

For example, the following command sets the region in the profile named username.

1
aws configure set region us-east-1 --profile username

To remove a setting, use an empty string as the value, or manually delete the setting in your config and credentials files in a text editor.

1
aws configure set cli_pager "" --profile username

aws configure get

You can retrieve any credentials or configuration settings you’ve set using aws configure get. Specify the profile that you want to view or modify with the --profile setting.

For example, the following command retrieves the region setting in the profile named username.

1
2
aws configure get region --profile username
us-east-1


Configuration settings and precedence

Configuration settings and precedence


Environment variables to configure the AWS CLI

Environment variables to configure the AWS CLI


List available profiles

list-profiles

List the profiles available to the AWS CLI.

CLI
1
aws configure list-profiles


List configuration data

List the AWS CLI configuration data. This command will show you the current configuration data. For each configuration item, it will show you the value, where the configuration value was retrieved, and the configuration variable name. For example, if you provide the AWS region in an environment variable, this command will show you the name of the region you’ve configured, it will tell you that this value came from an environment variable, and it will tell you the name of the environment variable.

CLI
1
aws configure list


Set

Set

Set a configuration value from the config file.

The aws configure set command can be used to set a single configuration value in the AWS config file.

Syntax

CLI
1
aws configure set [varname] [value] [--profile profile-name]

Set region for a specific profile.


S3

S3


ls

ls

List S3 objects and common prefixes under a prefix or all S3 buckets. Note that the –output and –no-paginate arguments are ignored for this command.

List all of my S3 buckets under us-east-1.