AWS Command Line Interface
[Pages:218]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 ? 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 .......................................................................... 1 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 user account ...................................................................................... 4 Step 3: Create an access key ID and secret access key ............................................................. 5 Next steps ......................................................................................................................... 6 Install/Update ............................................................................................................................ 6 Next steps ....................................................................................................................... 15 Past releases ............................................................................................................................ 15 Next steps ....................................................................................................................... 25 Docker .................................................................................................................................... 25 Prerequisites .................................................................................................................... 25 Run the official Docker image ............................................................................................ 25 Notes on interfaces and backwards compatibility of Docker image .......................................... 26 Use specific versions and tags ............................................................................................ 26 Update to the latest Docker image ..................................................................................... 27 Share host files, credentials, environment variables, and configuration .................................... 27 Shorten the Docker command ........................................................................................... 29 Add to path ............................................................................................................................. 30 Quick setup ............................................................................................................................. 31 New configuration quick setup ........................................................................................... 32 Using existing configuration and credentials files ................................................................. 32 Configuring the AWS CLI ................................................................................................................... 33 Configuration basics ................................................................................................................. 33 Quick configuration with aws configure .......................................................................... 34 Access key ID and secret access key .................................................................................... 34 Region ............................................................................................................................ 35 Output format ................................................................................................................. 35 Profiles ........................................................................................................................... 36 Configuration settings and precedence ................................................................................ 36 Configuration and credential file settings .................................................................................... 37 Where are configuration settings stored? ............................................................................. 37 Set and view configuration settings .................................................................................... 38 Supported config file settings ......................................................................................... 39 Named profiles ........................................................................................................................ 49 Creating named profiles .................................................................................................... 49 Using named profiles ........................................................................................................ 50 AWS Single Sign-On ................................................................................................................. 50 Configuring a named profile to use AWS SSO ...................................................................... 51 Using an AWS SSO enabled named profile .......................................................................... 54 Environment Variables .............................................................................................................. 55 How to set environment variables ...................................................................................... 56 AWS CLI supported environment variables ........................................................................... 57 Command line options .............................................................................................................. 60 Command completion ............................................................................................................... 63
iii
AWS Command Line Interface User Guide for Version 2
How it works ................................................................................................................... 63 Configuring command completion on Linux or macOS .......................................................... 64 Configuring command completion on Windows .................................................................... 66 Retries .................................................................................................................................... 67 Available retry modes ....................................................................................................... 67 Configuring a retry mode .................................................................................................. 69 Viewing logs of retry attempts .......................................................................................... 70 External credentials .................................................................................................................. 70 Using credentials for Amazon EC2 instance metadata ................................................................... 72 Prerequisites .................................................................................................................... 72 Configuring a profile for Amazon EC2 metadata ................................................................... 72 Using an HTTP proxy ................................................................................................................ 73 Authenticating to a proxy .................................................................................................. 73 Using a proxy on Amazon EC2 instances ............................................................................. 74 Using IAM roles ........................................................................................................................ 74 Configuring and using a role ............................................................................................. 75 Using MFA ....................................................................................................................... 77 Cross-account roles and external ID .................................................................................... 78 Specifying a role session name for easier auditing ................................................................ 78 Assume role with web identity ........................................................................................... 78 Clearing cached credentials ............................................................................................... 79 Using the AWS CLI ........................................................................................................................... 81 Getting Help ............................................................................................................................ 81 AWS CLI documentation .................................................................................................... 84 API documentation ........................................................................................................... 84 Additional help ................................................................................................................ 85 Command Structure ................................................................................................................. 85 Command structure .......................................................................................................... 85 Wait commands ............................................................................................................... 86 Specifying Parameter Values ...................................................................................................... 87 Common Parameter Types ................................................................................................. 87 Quotes with Strings .......................................................................................................... 90 Parameters from Files ....................................................................................................... 93 Generating a CLI Skeleton Template ................................................................................... 95 Shorthand Syntax ........................................................................................................... 103 Auto-prompt .......................................................................................................................... 104 How it works ................................................................................................................. 104 Auto-prompt features ..................................................................................................... 105 Auto-prompt modes ....................................................................................................... 107 Configure auto-prompt ................................................................................................... 107 Controlling Command Output .................................................................................................. 107 Output Format ............................................................................................................... 107 Pagination ..................................................................................................................... 114 Filtering ......................................................................................................................... 118 Return Codes ......................................................................................................................... 134 Wizards ................................................................................................................................. 135 How it works ................................................................................................................. 135 Aliases ................................................................................................................................... 136 Prerequisites .................................................................................................................. 136 Step 1: Creating the alias file ........................................................................................... 136 Step 2: Creating an alias ................................................................................................. 137 Step 3: Calling an alias .................................................................................................... 138 Alias repository examples ................................................................................................ 140 Resources ...................................................................................................................... 140 Using the AWS CLI with AWS Services ............................................................................................... 142 DynamoDB ............................................................................................................................. 142 Prerequisites .................................................................................................................. 143
iv
AWS Command Line Interface User Guide for Version 2
Creating and using DynamoDB tables ............................................................................... 143 Using DynamoDB Local ................................................................................................... 144 Resources ...................................................................................................................... 144 Amazon EC2 .......................................................................................................................... 145 Amazon EC2 Key Pairs .................................................................................................... 145 Amazon EC2 Security Groups ........................................................................................... 148 EC2 Instances ................................................................................................................. 152 Change EC2 type using bash scripting ............................................................................... 158 S3 Glacier .............................................................................................................................. 160 Prerequisites .................................................................................................................. 161 Create an Amazon S3 Glacier vault ................................................................................... 161 Prepare a file for uploading ............................................................................................. 161 Initiate a multipart upload and upload files ....................................................................... 162 Complete the upload ...................................................................................................... 163 Resources ...................................................................................................................... 164 IAM ....................................................................................................................................... 165 Creating IAM users and groups ......................................................................................... 165 Attaching an IAM managed policy to an IAM user ............................................................... 166 Setting an initial password for an IAM user ........................................................................ 167 Create an access key for an IAM user ................................................................................ 167 Amazon S3 ............................................................................................................................ 168 High-level (s3) commands ............................................................................................... 168 API-level (s3 api) commands ............................................................................................ 176 Bucket lifecycle scripting example (s3api) ......................................................................... 178 Amazon SNS .......................................................................................................................... 180 Create a topic ................................................................................................................ 181 Subscribe to a topic ........................................................................................................ 181 Publish to a topic ........................................................................................................... 182 Unsubscribe from a topic ................................................................................................ 182 Delete a topic ................................................................................................................ 182 Amazon SWF ......................................................................................................................... 182 List of Amazon SWF Commands ....................................................................................... 183 Working with Amazon SWF Domains ................................................................................ 185 Security ......................................................................................................................................... 188 Data Protection ...................................................................................................................... 188 Data encryption ............................................................................................................. 189 Identity and Access Management .............................................................................................. 189 Compliance Validation ............................................................................................................. 190 Enforcing TLS 1.2 ................................................................................................................... 190 Troubleshooting Errors .................................................................................................................... 191 General: Ensure you're running a recent version of the AWS CLI. ................................................... 191 General: Use the --debug option. ............................................................................................ 191 I get the error "command not found" when I run aws. ................................................................. 195 Possible cause: The operating system "path" was not updated during installation. ................... 195 I get "access denied" errors. ..................................................................................................... 195 Possible cause: The AWS CLI program file doesn't have "run" permission. ............................... 195 Possible cause: Your IAM identity doesn't have permission to perform the operation. ............... 196 I get an "invalid credentials" error. ............................................................................................ 196 Possible cause: The AWS CLI is reading credentials from an unexpected location. ..................... 196 Possible cause: Your computer's clock is out of sync. ........................................................... 196 I get a "signature does not match" error. ................................................................................... 197 Possible cause: Your clock is out of sync with the AWS servers. ............................................. 197 Possible cause: Your operating system is mishandling AWS secret keys that contain certain special characters. .......................................................................................................... 197 I get a "No Windows console found. Are you running cmd.exe?" error. ............................................ 198 I get a "[SSL: CERTIFICATE_ VERIFY_FAILED] certificate verify failed" error. ..................................... 198 Additional resources ................................................................................................................ 198
v
AWS Command Line Interface User Guide for Version 2 Migrating/Breaking Changes ............................................................................................................ 199
File encoding environment variable .......................................................................................... 199 Passing binary parameters ....................................................................................................... 199 Improved Amazon S3 property and tag handling during s3 copy operations ................................. 200 No automatic retrieval of webpages for parameters .................................................................... 201 Output paging ....................................................................................................................... 201 All date/time values in ISO 8601 format ................................................................................... 202 Improved AWS CloudFormation deployment handling ................................................................. 202 Amazon S3 and us-east-1 Region ............................................................................................. 203 AWS STS and regional endpoints .............................................................................................. 203 Deprecate ecr get-login .................................................................................................... 203 Changing support for [plugins] ............................................................................................ 204 No hidden aliases ................................................................................................................... 204 No longer supports api_versions .......................................................................................... 205 Uninstall ........................................................................................................................................ 206 Document History .......................................................................................................................... 209
vi
AWS Command Line Interface User Guide for Version 2 vii
AWS Command Line Interface User Guide for Version 2 About AWS CLI version 2
What is the AWS Command Line Interface?
The AWS Command Line Interface (AWS CLI) is an open source tool that enables you to interact with AWS services using commands in your command-line shell. With minimal configuration, the AWS CLI enables you to start running commands that implement functionality equivalent to that provided by the browser-based AWS Management Console from the command prompt in your terminal program:
? Linux shells ? Use common shell programs such as bash, zsh, and tcsh to run commands in Linux or macOS.
? Windows command line ? On Windows, run commands at the Windows command prompt or in PowerShell.
? Remotely ? Run commands on Amazon Elastic Compute Cloud (Amazon EC2) instances through a remote terminal program such as PuTTY or SSH, or with AWS Systems Manager.
All IaaS (infrastructure as a service) AWS administration, management, and access functions in the AWS Management Console are available in the AWS API and AWS CLI. New AWS IaaS features and services provide full AWS Management Console functionality through the API and CLI at launch or within 180 days of launch.
The AWS CLI provides direct access to the public APIs of AWS services. You can explore a service's capabilities with the AWS CLI, and develop shell scripts to manage your resources. In addition to the low-level, API-equivalent commands, several AWS services provide customizations for the AWS CLI. Customizations can include higher-level commands that simplify using a service with a complex API.
About AWS CLI version 2
The AWS CLI version 2 is the most recent major version of the AWS CLI and supports all of the latest features. Some features introduced in version 2 are not backported to version 1 and you must upgrade to access those features. There are some "breaking" changes from version 1 that might require you to change your scripts. For a list of breaking changes in version 2, see Breaking changes ? Migrating from AWS CLI version 1 to version 2 (p. 199).
The AWS CLI version 2 is available to install only as a bundled installer. While you may find it in package managers, these are unsupported and unofficial packages that are not produced or managed by AWS. We recommend that you install the AWS CLI from only the official AWS distribution points, as documented in this guide.
To install the AWS CLI version 2, see the section called "Install/Update" (p. 6).
For version history, see the AWS CLI version 2 Changelog on GitHub.
Maintenance and support for SDK major versions
For information about maintenance and support for SDK major versions and their underlying dependencies, see the following in the AWS SDKs and Tools Reference Guide:
1
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- command line to reset password
- powershell command line switches
- powershell run command line exe
- run command line from powershell
- command line pdf
- windows command line tutorial pdf
- windows 10 command line reference
- powershell command line switch parameter
- linux command line pdf
- command line reference online help
- command line reference windows 10
- command line prompts