AWS Command Line Interface

AWS Command Line Interface

User Guide

AWS Command Line Interface User Guide

AWS Command Line Interface: User Guide

Copyright ? 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

Table of Contents

...................................................................................................................................................... vii What Is the AWS CLI? ......................................................................................................................... 1

AWS CLI versions ....................................................................................................................... 1 Maintenance and support for SDK major versions .......................................................................... 1 About Amazon Web Services ....................................................................................................... 2 AWS CLI versions ....................................................................................................................... 2

AWS CLI version 2 .............................................................................................................. 2 AWS CLI version 1 .............................................................................................................. 2 Using the examples .................................................................................................................... 3 Additional documentation and resources ....................................................................................... 4 AWS CLI documentation and resources ................................................................................. 4 Other AWS SDKs ................................................................................................................ 4 Installing the AWS CLI ........................................................................................................................ 5 AWS CLI version 2 ...................................................................................................................... 5 Docker .............................................................................................................................. 5 Linux .............................................................................................................................. 11 macOS ............................................................................................................................ 19 Windows ......................................................................................................................... 23 AWS CLI version 1 .................................................................................................................... 25 Amazon Linux .................................................................................................................. 25 Linux .............................................................................................................................. 26 macOS ............................................................................................................................ 33 Windows ......................................................................................................................... 39 Virtualenv ........................................................................................................................ 42 Configuring the AWS CLI ................................................................................................................... 45 Configuration basics ................................................................................................................. 45 Quick configuration with aws configure .......................................................................... 46 Access key ID and secret access key .................................................................................... 46 Region ............................................................................................................................ 47 Output format ................................................................................................................. 47 Profiles ........................................................................................................................... 47 Configuration settings and precedence ................................................................................ 48 Configuration and credential file settings .................................................................................... 48 Where are configuration settings stored? ............................................................................. 49 Set and view configuration settings .................................................................................... 49 Supported config file settings ......................................................................................... 51 Named profiles ........................................................................................................................ 61 Using profiles with the AWS CLI ......................................................................................... 62 Configuring the AWS CLI to use AWS Single Sign-On .................................................................... 62 Configuring a named profile to use AWS SSO ...................................................................... 63 Using an AWS SSO enabled named profile .......................................................................... 66 Environment Variables .............................................................................................................. 68 How to set environment variables ...................................................................................... 68 AWS CLI supported environment variables ........................................................................... 69 Command line options .............................................................................................................. 72 Command completion ............................................................................................................... 75 How it works ................................................................................................................... 75 Configuring command completion on Linux or macOS .......................................................... 76 Configuring command completion on Windows .................................................................... 78 Verify command completion .............................................................................................. 79 Retries .................................................................................................................................... 79 Available retry modes ....................................................................................................... 79 Configuring a retry mode .................................................................................................. 81 Viewing logs of retry attempts .......................................................................................... 82

iii

AWS Command Line Interface User Guide

Sourcing credentials with an external process .............................................................................. 82 Using credentials for Amazon EC2 instance metadata ................................................................... 83

Prerequisites .................................................................................................................... 84 Configuring a profile for Amazon EC2 metadata ................................................................... 84 Using an HTTP proxy ................................................................................................................ 85 Authenticating to a proxy .................................................................................................. 85 Using a proxy on Amazon EC2 instances ............................................................................. 85 Using an IAM role in the AWS CLI .............................................................................................. 86 Configuring and using a role ............................................................................................. 87 Using MFA ....................................................................................................................... 88 Cross-account roles and external ID .................................................................................... 89 Specifying a role session name for easier auditing ................................................................ 90 Assume role with web identity ........................................................................................... 90 Clearing cached credentials ............................................................................................... 91 Using the AWS CLI ........................................................................................................................... 92 Getting Help ............................................................................................................................ 92 AWS CLI documentation .................................................................................................... 95 API documentation ........................................................................................................... 95 Command Structure ................................................................................................................. 96 Command structure .......................................................................................................... 96 Wait commands ............................................................................................................... 97 Specifying Parameter Values ...................................................................................................... 98 Common Parameter Types ................................................................................................. 98 Quotes with Strings ........................................................................................................ 100 Parameters from Files ..................................................................................................... 103 Generating a CLI Skeleton Template ................................................................................. 105 Shorthand Syntax ........................................................................................................... 113 Auto-prompt .......................................................................................................................... 114 How it works ................................................................................................................. 114 Auto-prompt features ..................................................................................................... 115 Auto-prompt modes ....................................................................................................... 117 Configure auto-prompt ................................................................................................... 117 Controlling Command Output .................................................................................................. 117 Output Format ............................................................................................................... 118 Pagination ..................................................................................................................... 124 Filtering ......................................................................................................................... 128 Return Codes ......................................................................................................................... 144 Wizards ................................................................................................................................. 145 How it works ................................................................................................................. 145 Aliases ................................................................................................................................... 146 Prerequisites .................................................................................................................. 146 Step 1: Creating the alias file ........................................................................................... 147 Step 2: Creating an alias ................................................................................................. 147 Step 3: Calling an alias .................................................................................................... 149 Alias repository examples ................................................................................................ 150 Resources ...................................................................................................................... 151 Using the AWS CLI with AWS Services ............................................................................................... 152 DynamoDB ............................................................................................................................. 152 Prerequisites .................................................................................................................. 152 Creating and using DynamoDB tables ............................................................................... 153 Using DynamoDB Local ................................................................................................... 154 Resources ...................................................................................................................... 154 Amazon EC2 .......................................................................................................................... 154 Amazon EC2 Key Pairs .................................................................................................... 155 Amazon EC2 Security Groups ........................................................................................... 157 EC2 Instances ................................................................................................................. 162 Change EC2 type using bash scripting ............................................................................... 168

iv

AWS Command Line Interface User Guide

S3 Glacier .............................................................................................................................. 170 Create an Amazon S3 Glacier vault ................................................................................... 170 Prepare a file for uploading ............................................................................................. 171 Initiate a multipart upload and upload files ....................................................................... 171 Complete the upload ...................................................................................................... 172

IAM ....................................................................................................................................... 174 Creating IAM users and groups ......................................................................................... 174 Attaching an IAM managed policy to an IAM user ............................................................... 175 Setting an initial password for an IAM user ........................................................................ 176 Create an access key for an IAM user ................................................................................ 176

Amazon S3 ............................................................................................................................ 177 High-level (s3) commands ............................................................................................... 177 API-level (s3 api) commands ............................................................................................ 185 Bucket lifecycle scripting example (s3api) ......................................................................... 187

Amazon SNS .......................................................................................................................... 189 Create a topic ................................................................................................................ 190 Subscribe to a topic ........................................................................................................ 190 Publish to a topic ........................................................................................................... 190 Unsubscribe from a topic ................................................................................................ 191 Delete a topic ................................................................................................................ 191

Amazon SWF ......................................................................................................................... 191 List of Amazon SWF Commands ....................................................................................... 192 Working with Amazon SWF Domains ................................................................................ 194

Security ......................................................................................................................................... 197 Data Protection ...................................................................................................................... 197 Data encryption ............................................................................................................. 198 Identity and Access Management .............................................................................................. 198 Compliance Validation ............................................................................................................. 199 Enforcing TLS 1.2 ................................................................................................................... 199 Configuring the AWS CLI version 1 to enforce a minimum version of TLS 1.2 minimum ............. 200 Configuring the AWS CLI version 2 to enforce a minimum version of TLS 1.2 .......................... 202

Troubleshooting Errors .................................................................................................................... 203 General: Ensure you're running a recent version of the AWS CLI. ................................................... 203 General: Use the --debug option. ............................................................................................ 203 I get the error "command not found" when I run aws. ................................................................. 207 Possible cause: The operating system "path" was not updated during installation. ................... 207 I get "access denied" errors. ..................................................................................................... 207 Possible cause: The AWS CLI program file doesn't have "run" permission. ............................... 207 Possible cause: Your IAM identity doesn't have permission to perform the operation. ............... 208 I get an "invalid credentials" error. ............................................................................................ 208 Possible cause: The AWS CLI is reading credentials from an unexpected location. ..................... 208 Possible cause: Your computer's clock is out of sync. ........................................................... 208 I get a "signature does not match" error. ................................................................................... 209 Possible cause: Your clock is out of sync with the AWS servers. ............................................. 209 Possible cause: Your operating system is mishandling AWS secret keys that contain certain special characters. .......................................................................................................... 209 I get a "No Windows console found. Are you running cmd.exe?" error. ............................................ 210 I get a "[SSL: CERTIFICATE_ VERIFY_FAILED] certificate verify failed" error. ..................................... 210 Resources .............................................................................................................................. 210

Migrating/Breaking Changes ............................................................................................................ 211 File encoding environment variable .......................................................................................... 211 Passing binary parameters ....................................................................................................... 211 Improved Amazon S3 property and tag handling during s3 copy operations ................................. 212 No automatic retrieval of webpages for parameters .................................................................... 213 Output paging ....................................................................................................................... 213 All date/time values in ISO 8601 format ................................................................................... 214 Improved AWS CloudFormation deployment handling ................................................................. 214

v

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

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

Google Online Preview   Download