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
Check if you have a previous AWS CLI version
1 | which aws |
Install and update the AWS CLI version 2 using Homebrew
1 | brew install awscli |
Verify the installation
1 | which aws |
AWS CLI Configuration
Configure
Configuration basics
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:
1 | aws configure |
Profiles (for additional users)
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
.
1 | aws configure --profile Zacks |
You can then specify a --profile profilename
and use the credentials and settings stored under that name.
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
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
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 |
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 | aws configure get region --profile username |
Configuration settings and precedence
Environment variables to configure the AWS CLI
List available profiles
List the profiles available to the AWS 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.
1 | aws configure list |
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
1 | aws configure set [varname] [value] [--profile profile-name] |
Set region for a specific profile.
S3
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
.