A command-line interface (CLI) lets you interact with software by entering commands in a terminal. The AWS CLI lets you manage and access AWS services this way. Like the Management Console and software development kits (SDKs), it provides a way to make requests to the AWS API. section 1.7.2 section 1.7
Use the CLI when a task is easier to repeat than to click through: upload files to object storage, inspect networking configuration, or create infrastructure from a blueprint. Multiple CLI calls can be chained in a Bash or PowerShell script, including one run by a continuous integration server such as Jenkins. An SDK serves a different need: making API calls from application code. CloudFormation instead describes the infrastructure’s desired state in a template. section 1.7.2 section 4.6
A small AWS CLI setup and check:
- Create an IAM user with programmatic access in the AWS Management Console and obtain its access key ID and secret access key. Avoid using the root account for CLI access. The illustrated setup grants AdministratorAccess, so its credentials must be treated as top secret. section 4.2.2
- In a local terminal, run `aws configure`. Enter the access key ID, secret access key, a default region such as `us-east-1`, and an output format such as `json`. section 4.2.2
- Run `aws ec2 describe-regions` to request a list of regions and inspect the JSON response. section 4.2.2
“CLI” can also mean the command interface of an application you build, not just the AWS CLI. A terminal-based to-do application, for example, defines commands to add users, list tasks, and mark tasks done. Its commands are described with docopt; the application uses an AWS SDK to communicate with DynamoDB. section 12.1
Listing 12.1 CLI description language docopt: Using nodetodo (cli.txt)
nodetodo Usage: nodetodo user-add <uid> <email> <phone> nodetodo user-rm <uid> nodetodo user-ls [--limit=<limit>] [--next=<id>] #1 nodetodo user <uid> nodetodo task-add <uid> <description> \ [<category>] [--dueat=<yyyymmdd>] #2 nodetodo task-rm <uid> <tid> nodetodo task-ls <uid> [<category>] \ [--overdue|--due|--withoutdue|--futuredue] #3 nodetodo task-la <category> \ [--overdue|--due|--withoutdue|--futuredue] nodetodo task-done <uid> <tid> nodetodo -h | --help #4 nodetodo --version #5 Options: -h --help Show this screen. --version Show version. #1 The named parameters limit and next are optional. #2 The category parameter is optional. #3 Pipe indicates either/or. #4 help prints information about how to use nodetodo. #5 Version information
The command description shows how an application CLI names actions, accepts required and optional arguments, and provides help. section 12.1








