AWS Command Line Interface

AWS Command Line Interface

User Guide for Version 2

AWS Command Line Interface User Guide for Version 2

AWS Command Line Interface: User Guide for Version 2

Copyright ? 2023 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored by Amazon.

AWS Command Line Interface User Guide for Version 2

Table of Contents

...................................................................................................................................................... vii About the AWS CLI ............................................................................................................................ 1

About AWS CLI version 2 ............................................................................................................ 1 Maintenance and support for SDK major versions .......................................................................... 2 About Amazon Web Services ....................................................................................................... 2 About the examples ................................................................................................................... 2 Additional documentation and resources ....................................................................................... 3

AWS CLI documentation and resources ................................................................................. 3 Other AWS SDKs ................................................................................................................ 3 Get started ........................................................................................................................................ 4 Prerequisites .............................................................................................................................. 4 Create an IAM or IAM Identity Center account ....................................................................... 4 Next steps ......................................................................................................................... 5 Install/Update ............................................................................................................................ 5 AWS CLI install and update instructions ................................................................................ 5 Troubleshooting AWS CLI install and uninstall errors ............................................................. 14 Next steps ....................................................................................................................... 14 Past releases ............................................................................................................................ 14 Troubleshooting AWS CLI install and uninstall errors ............................................................. 26 Next steps ....................................................................................................................... 26 Build and install from source ..................................................................................................... 26 Why build from source? .................................................................................................... 26 Quicksteps ....................................................................................................................... 27 Step 1: Setup all requirements ........................................................................................... 28 Step 2: Configuring the AWS CLI source installation .............................................................. 31 Step 3: Building the AWS CLI ............................................................................................. 35 Step 4: Installing the AWS CLI ........................................................................................... 36 Step 5: Verifying the AWS CLI installation ........................................................................... 37 Workflow examples .......................................................................................................... 37 Troubleshooting AWS CLI install and uninstall errors ............................................................. 39 Next steps ....................................................................................................................... 39 Amazon ECR Public/Docker ....................................................................................................... 39 Prerequisites .................................................................................................................... 40 Deciding between Amazon ECR Public and Docker Hub ......................................................... 40 Run the official images ..................................................................................................... 40 Notes on interfaces and backwards compatibility of the official images ................................... 41 Use specific versions and tags ............................................................................................ 41 Update to the latest official image ..................................................................................... 42 Share host files, credentials, environment variables, and configuration .................................... 42 Shorten the docker run command ...................................................................................... 47 Setup ...................................................................................................................................... 49 Gather your credential information for programmatic access .................................................. 49 Setting up new configuration and credentials ...................................................................... 50 Using existing configuration and credentials files ................................................................. 55 Configure the AWS CLI ...................................................................................................................... 56 Configuration and credentials precedence ................................................................................... 56 Additional topics in this section ................................................................................................. 57 Configuration and credential file settings .................................................................................... 57 Format of the configuration and credential files ................................................................... 57 Where are configuration settings stored? ............................................................................. 63 Using named profiles ........................................................................................................ 63 Set and view configuration settings using commands ............................................................ 64 Setting new configuration and credentials command examples .............................................. 66 Supported config file settings ......................................................................................... 68

iii

AWS Command Line Interface User Guide for Version 2

Environment Variables .............................................................................................................. 79 How to set environment variables ...................................................................................... 80 AWS CLI supported environment variables ........................................................................... 81

Command line options .............................................................................................................. 86 How to use command line options ..................................................................................... 86 AWS CLI supported global command line options ................................................................. 86 Common uses of command line options .............................................................................. 90

Command completion ............................................................................................................... 90 How it works ................................................................................................................... 90 Configuring command completion on Linux or macOS .......................................................... 91 Configuring command completion on Windows .................................................................... 93

Retries .................................................................................................................................... 94 Available retry modes ....................................................................................................... 95 Configuring a retry mode .................................................................................................. 96 Viewing logs of retry attempts .......................................................................................... 97

Use an HTTP proxy ................................................................................................................... 98 Using the examples .......................................................................................................... 98 Authenticating to a proxy .................................................................................................. 99 Using a proxy on Amazon EC2 instances ............................................................................. 99 Troubleshooting ............................................................................................................. 100

Endpoints .............................................................................................................................. 100 Set endpoint for a single command .................................................................................. 100 Set global endpoint for all AWS services ........................................................................... 100 Set service-specific endpoints .......................................................................................... 101 Endpoint configuration and settings precedence ................................................................. 116

Authentication and access credentials ............................................................................................... 118 Configuration and credential precedence ................................................................................... 118 Additional topics in this section ................................................................................................ 119 IAM Identity Center authentication ........................................................................................... 119 Configure automatic token refresh .................................................................................... 120 Configure legacy non-refreshable ..................................................................................... 125 Using an IAM Identity Center profile ................................................................................. 128 Short-term credentials ............................................................................................................ 130 IAM roles ............................................................................................................................... 131 Prerequisites .................................................................................................................. 132 Overview of using IAM roles ............................................................................................ 132 Configuring and using a role ............................................................................................ 133 Using MFA ..................................................................................................................... 134 Cross-account roles and external ID .................................................................................. 135 Specifying a role session name for easier auditing .............................................................. 135 Assume role with web identity ......................................................................................... 136 Clearing cached credentials .............................................................................................. 137 IAM users .............................................................................................................................. 137 Step 1: Create your IAM user ........................................................................................... 137 Step 2: Get your access keys ............................................................................................ 138 Configure the AWS CLI .................................................................................................... 138 Use credentials for Amazon EC2 instance metadata .................................................................... 139 Prerequisites .................................................................................................................. 140 Configuring a profile for Amazon EC2 metadata ................................................................. 140 External credentials ................................................................................................................ 141

Use the AWS CLI ............................................................................................................................ 143 Get Help ................................................................................................................................ 143 The built-in AWS CLI help command ................................................................................. 143 AWS CLI reference guide ................................................................................................. 147 API documentation ......................................................................................................... 147 Troubleshooting errors .................................................................................................... 147 Additional help .............................................................................................................. 147

iv

AWS Command Line Interface User Guide for Version 2

Command Structure ................................................................................................................ 147 Command structure ........................................................................................................ 148 Wait commands ............................................................................................................. 148

Specify Parameter Values ........................................................................................................ 149 Common Parameter Types ............................................................................................... 150 Quotes with Strings ........................................................................................................ 153 Parameters from Files ..................................................................................................... 156 Generate a CLI Skeleton Template .................................................................................... 158 Shorthand Syntax ........................................................................................................... 166

Auto-prompt .......................................................................................................................... 168 How it works ................................................................................................................. 168 Auto-prompt features ..................................................................................................... 168 Auto-prompt modes ....................................................................................................... 170 Configure auto-prompt ................................................................................................... 171

Control Command Output ....................................................................................................... 171 Output Format ............................................................................................................... 171 Pagination ..................................................................................................................... 178 Filter output .................................................................................................................. 182

Return Codes ......................................................................................................................... 198 Wizards ................................................................................................................................. 199

How it works ................................................................................................................. 199 Aliases ................................................................................................................................... 200

Prerequisites .................................................................................................................. 200 Step 1: Creating the alias file ........................................................................................... 201 Step 2: Creating an alias ................................................................................................. 201 Step 3: Calling an alias .................................................................................................... 203 Alias repository examples ................................................................................................ 205 Resources ...................................................................................................................... 206 Code examples ............................................................................................................................... 207 Guided command examples ..................................................................................................... 207 DynamoDB ..................................................................................................................... 207 Amazon EC2 .................................................................................................................. 210 S3 Glacier ...................................................................................................................... 222 IAM ............................................................................................................................... 227 Amazon S3 .................................................................................................................... 230 Amazon SNS .................................................................................................................. 243 Amazon SWF ................................................................................................................. 245 Bash script examples .............................................................................................................. 250 Actions and scenarios ...................................................................................................... 250 Security ......................................................................................................................................... 359 Data Protection ...................................................................................................................... 359 Data encryption ............................................................................................................. 360 Identity and Access Management .............................................................................................. 360 Audience ....................................................................................................................... 361 Authenticating with identities .......................................................................................... 361 Managing access using policies ......................................................................................... 363 How AWS services work with IAM ..................................................................................... 365 Troubleshooting AWS identity and access .......................................................................... 365 Compliance Validation ............................................................................................................. 366 Resilience .............................................................................................................................. 367 Infrastructure Security ............................................................................................................. 367 Enforcing a minimum TLS version ............................................................................................ 368 Troubleshoot errors ........................................................................................................................ 369 General troubleshooting to try first .......................................................................................... 369 Check your AWS CLI command formatting ......................................................................... 369 Confirm that you're running a recent version of the AWS CLI ................................................ 370 Use the --debug option ................................................................................................. 370

v

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download