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 Using the examples .................................................................................................................... 2 Additional documentation and resources ....................................................................................... 3

AWS CLI documentation and resources ................................................................................. 3 Other AWS SDKs ................................................................................................................ 3 Getting started .................................................................................................................................. 4 Prerequisites .............................................................................................................................. 4 Step 1: Sign up to AWS ...................................................................................................... 4 Step 2: Create an IAM account ............................................................................................. 4 Step 3: Create an access key ID and secret access key ............................................................. 5 Next steps ......................................................................................................................... 6 Install/Update ............................................................................................................................ 6 AWS CLI install and update instructions ................................................................................ 7 Troubleshooting AWS CLI install and uninstall errors ............................................................. 15 Next steps ....................................................................................................................... 15 Past releases ............................................................................................................................ 15 Troubleshooting AWS CLI install and uninstall errors ............................................................. 27 Next steps ....................................................................................................................... 27 Build and install from source ..................................................................................................... 27 Why build from source? .................................................................................................... 27 Quicksteps ....................................................................................................................... 28 Step 1: Setup all requirements ........................................................................................... 29 Step 2: Configuring the AWS CLI source installation .............................................................. 32 Step 3: Building the AWS CLI ............................................................................................. 36 Step 4: Installing the AWS CLI ........................................................................................... 37 Step 5: Verifying the AWS CLI installation ........................................................................... 38 Workflow examples .......................................................................................................... 38 Troubleshooting AWS CLI install and uninstall errors ............................................................. 40 Next steps ....................................................................................................................... 40 Amazon ECR Public/Docker ....................................................................................................... 40 Prerequisites .................................................................................................................... 41 Deciding between Amazon ECR Public and Docker Hub ......................................................... 41 Run the official images ..................................................................................................... 41 Notes on interfaces and backwards compatibility of the official images ................................... 42 Use specific versions and tags ............................................................................................ 42 Update to the latest official image ..................................................................................... 43 Share host files, credentials, environment variables, and configuration .................................... 43 Shorten the docker run command ...................................................................................... 48 Quick setup ............................................................................................................................. 50 New configuration quick setup ........................................................................................... 50 Using existing configuration and credentials files ................................................................. 51 Configuring the AWS CLI ................................................................................................................... 52 Configuration basics ................................................................................................................. 52 Quick configuration with aws configure .......................................................................... 53 Access key ID and secret access key .................................................................................... 53 Region ............................................................................................................................ 55 Output format ................................................................................................................. 55 Profiles ........................................................................................................................... 55 Configuration settings and precedence ................................................................................ 56 Configuration and credential file settings .................................................................................... 56

iii

AWS Command Line Interface User Guide for Version 2

Where are configuration settings stored? ............................................................................. 56 Set and view configuration settings .................................................................................... 57 Supported config file settings ......................................................................................... 59 Named profiles ........................................................................................................................ 69 Creating named profiles .................................................................................................... 69 Using named profiles ........................................................................................................ 70 AWS IAM Identity Center (successor to AWS Single Sign-On) .......................................................... 70 Configure automatic token refresh ..................................................................................... 71 Configure legacy non-refreshable ....................................................................................... 75 Using AWS IAM Identity Center (successor to AWS Single Sign-On) ......................................... 78 Environment Variables .............................................................................................................. 81 How to set environment variables ...................................................................................... 81 AWS CLI supported environment variables ........................................................................... 82 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 .............................................................................. 89 Command completion ............................................................................................................... 90 How it works ................................................................................................................... 90 Configuring command completion on Linux or macOS .......................................................... 90 Configuring command completion on Windows .................................................................... 93 Retries .................................................................................................................................... 94 Available retry modes ....................................................................................................... 94 Configuring a retry mode .................................................................................................. 96 Viewing logs of retry attempts .......................................................................................... 97 External credentials .................................................................................................................. 97 Using credentials for Amazon EC2 instance metadata ................................................................... 98 Prerequisites .................................................................................................................... 99 Configuring a profile for Amazon EC2 metadata ................................................................... 99 Using an HTTP proxy .............................................................................................................. 100 Using the examples ........................................................................................................ 100 Authenticating to a proxy ................................................................................................ 101 Using a proxy on Amazon EC2 instances ............................................................................ 101 Using IAM roles ...................................................................................................................... 101 Prerequisites .................................................................................................................. 102 Overview of using IAM roles ............................................................................................ 102 Configuring and using a role ............................................................................................ 103 Using MFA ..................................................................................................................... 104 Cross-account roles and external ID .................................................................................. 105 Specifying a role session name for easier auditing .............................................................. 105 Assume role with web identity ......................................................................................... 106 Clearing cached credentials .............................................................................................. 107 Using the AWS CLI ......................................................................................................................... 108 Getting Help .......................................................................................................................... 108 The built-in AWS CLI help command ................................................................................. 108 AWS CLI reference guide ................................................................................................. 112 API documentation ......................................................................................................... 112 Troubleshooting errors .................................................................................................... 112 Additional help .............................................................................................................. 112 Command Structure ................................................................................................................ 112 Command structure ........................................................................................................ 113 Wait commands ............................................................................................................. 113 Specifying Parameter Values .................................................................................................... 114 Common Parameter Types ............................................................................................... 115 Quotes with Strings ........................................................................................................ 118 Parameters from Files ..................................................................................................... 121 Generating a CLI Skeleton Template ................................................................................. 123

iv

AWS Command Line Interface User Guide for Version 2

Shorthand Syntax ........................................................................................................... 131 Auto-prompt .......................................................................................................................... 133

How it works ................................................................................................................. 133 Auto-prompt features ..................................................................................................... 133 Auto-prompt modes ....................................................................................................... 135 Configure auto-prompt ................................................................................................... 136 Controlling Command Output .................................................................................................. 136 Output Format ............................................................................................................... 136 Pagination ..................................................................................................................... 142 Filtering ......................................................................................................................... 146 Return Codes ......................................................................................................................... 162 Wizards ................................................................................................................................. 163 How it works ................................................................................................................. 164 Aliases ................................................................................................................................... 164 Prerequisites .................................................................................................................. 165 Step 1: Creating the alias file ........................................................................................... 165 Step 2: Creating an alias ................................................................................................. 166 Step 3: Calling an alias .................................................................................................... 168 Alias repository examples ................................................................................................ 169 Resources ...................................................................................................................... 170 Using the AWS CLI with AWS Services ............................................................................................... 171 DynamoDB ............................................................................................................................. 171 Prerequisites .................................................................................................................. 172 Creating and using DynamoDB tables ............................................................................... 172 Using DynamoDB Local ................................................................................................... 173 Resources ...................................................................................................................... 173 Amazon EC2 .......................................................................................................................... 174 Amazon EC2 Key Pairs .................................................................................................... 174 Amazon EC2 Security Groups ........................................................................................... 177 EC2 Instances ................................................................................................................. 180 Change EC2 type using bash scripting ............................................................................... 185 S3 Glacier .............................................................................................................................. 187 Prerequisites .................................................................................................................. 187 Create an Amazon S3 Glacier vault ................................................................................... 188 Prepare a file for uploading ............................................................................................. 188 Initiate a multipart upload and upload files ....................................................................... 188 Complete the upload ...................................................................................................... 189 Resources ...................................................................................................................... 191 IAM ....................................................................................................................................... 191 Creating IAM users and groups ......................................................................................... 192 Attaching an IAM managed policy to a user ....................................................................... 193 Setting an initial password for an IAM user ........................................................................ 194 Create an access key for an IAM user ................................................................................ 194 Amazon S3 ............................................................................................................................ 195 High-level (s3) commands ............................................................................................... 195 API-level (s3 api) commands ............................................................................................ 203 Bucket lifecycle scripting example (s3api) ......................................................................... 205 Amazon SNS .......................................................................................................................... 207 Create a topic ................................................................................................................ 208 Subscribe to a topic ........................................................................................................ 208 Publish to a topic ........................................................................................................... 209 Unsubscribe from a topic ................................................................................................ 209 Delete a topic ................................................................................................................ 209 Amazon SWF ......................................................................................................................... 209 List of Amazon SWF Commands ....................................................................................... 210 Working with Amazon SWF Domains ................................................................................ 212 Security ......................................................................................................................................... 215

v

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

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

Google Online Preview   Download