获取有关 Amazon CLI 的帮助 - Amazon Command Line Interface
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

获取有关 Amazon CLI 的帮助

本主题介绍如何访问 Amazon Command Line Interface (Amazon CLI) 的帮助内容。

内置 Amazon CLI 帮助命令

使用 Amazon Command Line Interface (Amazon CLI) 时,您可以获得任何命令的帮助。为此,只需在命令名称末尾键入 help

例如,以下命令显示常规 Amazon CLI 选项和可用顶层命令的帮助。

$ aws help

以下命令显示可用的 Amazon Elastic Compute Cloud (Amazon EC2) 特定命令。

$ aws ec2 help

以下示例显示 Amazon EC2 DescribeInstances 操作的详细帮助。帮助包括对其输入参数、可用筛选条件以及作为输出包含的内容的描述。它还包含说明如何键入命令的常见变体的示例。

$ aws ec2 describe-instances help

每个命令的帮助分为六个部分:

名称

命令的名称。

NAME describe-instances -
说明

命令调用的 API 操作的描述。

DESCRIPTION Describes one or more of your instances. If you specify one or more instance IDs, Amazon EC2 returns information for those instances. If you do not specify instance IDs, Amazon EC2 returns information for all relevant instances. If you specify an instance ID that is not valid, an error is returned. If you specify an instance that you do not own, it is not included in the returned results. ...
摘要

使用命令及其选项的基本语法。如果某个选项显示在方括号中,则表示该选项是可选的、具有默认值或具有可使用的替代选项。

SYNOPSIS describe-instances [--dry-run | --no-dry-run] [--instance-ids <value>] [--filters <value>] [--cli-input-json <value>] [--starting-token <value>] [--page-size <value>] [--max-items <value>] [--generate-cli-skeleton]

例如,describe-instances 具有描述当前账户和 Amazon 区域中的所有实例的默认行为。您可以选择指定 instance-ids 列表来描述一个或多个实例;dry-run 是不接受值的可选布尔标志。要使用布尔标志,请指定其中一个显示的值,在本例中为 --dry-run--no-dry-run。同样,--generate-cli-skeleton 不使用值。如果某个选项的使用存在条件,则在 OPTIONS 部分中描述这些条件,或在示例中显示这些条件。

选项

对摘要中显示的每个选项的描述。

OPTIONS --dry-run | --no-dry-run (boolean) Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRun- Operation . Otherwise, it is UnauthorizedOperation . --instance-ids (list) One or more instance IDs. Default: Describes all your instances. ...
示例

一些示例,用于显示命令及其选项的使用。如果您需要的命令或用例没有示例可用,请使用本页面上的反馈链接请求一个示例,或在命令的帮助页上的 Amazon CLI 命令参考中请求一个示例。

EXAMPLES To describe an Amazon EC2 instance Command: aws ec2 describe-instances --instance-ids i-5203422c To describe all instances with the instance type m1.small Command: aws ec2 describe-instances --filters "Name=instance-type,Values=m1.small" To describe all instances with an Owner tag Command: aws ec2 describe-instances --filters "Name=tag-key,Values=Owner" ...
输出

来自的响应中包含的每个字段和数据类型的描述Amazon

对于 describe-instances,输出是预留对象的列表,每个列表都包含若干字段和对象,这些字段和对象包含与其关联的实例的相关信息。此信息来自 Amazon EC2 使用的预留数据类型的 API 文档

OUTPUT Reservations -> (list) One or more reservations. (structure) Describes a reservation. ReservationId -> (string) The ID of the reservation. OwnerId -> (string) The ID of the Amazon account that owns the reservation. RequesterId -> (string) The ID of the requester that launched the instances on your behalf (for example, Amazon Management Console or Auto Scaling). Groups -> (list) One or more security groups. (structure) Describes a security group. GroupName -> (string) The name of the security group. GroupId -> (string) The ID of the security group. Instances -> (list) One or more instances. (structure) Describes an instance. InstanceId -> (string) The ID of the instance. ImageId -> (string) The ID of the AMI used to launch the instance. State -> (structure) The current state of the instance. Code -> (integer) The low byte represents the state. The high byte is an opaque internal value and should be ignored. ...

当 Amazon CLI 将输出呈现为 JSON 时,输出将成为预留对象的数组,类似于以下示例。

{ "Reservations": [ { "OwnerId": "012345678901", "ReservationId": "r-4c58f8a0", "Groups": [], "RequesterId": "012345678901", "Instances": [ { "Monitoring": { "State": "disabled" }, "PublicDnsName": "ec2-52-74-16-12.us-west-2.compute.amazonaws.com", "State": { "Code": 16, "Name": "running" }, ...

每个预留对象都包含一些描述预留的字段和一组实例对象,每个实例对象又带有用来描述它的字段(如 PublicDnsName)和对象(如 State)。

Windows 用户

您可以通过管道 (|) 将 help 命令的输出发送到 more 命令以便每次查看一页帮助文件。按空格键或 PgDn 键可查看文档的更多内容,按 q 可退出。

C:\> aws ec2 describe-instances help | more

Amazon CLI 参考指南

帮助文件包含无法通过命令行查看或导航至的链接。您可以使用线上 Amazon CLI 版本 2 参考指南查看这些链接,并与其交互。参考指南还包含所有 Amazon CLI 命令的帮助内容。将显示这些说明以方便在手机、平板电脑或桌面屏幕进行浏览和查看。

API 文档

Amazon CLI 中的所有命令对应于对 Amazon 服务的公用 API 发出的请求。具有公用 API 的每项服务都有一个 API 引用,可从Amazon文档网站上该服务的主页找到。API 参考的内容因 API 的构造方式以及所用协议而有所不同。通常,API 参考包含有关该 API 支持的操作、发送到该服务和从该服务发送的数据以及该服务可能报告的任何错误状况的详细信息。

API 文档的各部分
  • Actions(操作)– 有关每个操作及其参数(包括对长度或内容以及默认值的约束)的详细信息。它列出了此操作可能发生的错误。每个操作对应于 Amazon CLI 中的一个子命令。

  • Data Types(数据类型)– 有关命令可能需要作为参数或在响应请求时要返回的结构的详细信息。

  • Common Parameters (常用参数)– 有关由服务的所有操作共享的参数的详细信息。

  • Common Errors(常见错误)– 有关可能由服务的任意操作返回的错误的详细信息。

每个部分的名称和可用性可能根据具体服务而不同。

特定于服务的 CLI

与以前创建单个 Amazon CLI 以处理所有服务不同,有些服务还有单独的 CLI。这些特定于服务的 CLI 具有单独的文档,该服务的文档页面包含指向该文档的链接。特定于服务的 CLI 的文档不适用于 Amazon CLI。

纠正错误

如需帮助诊断和修复 Amazon CLI 错误,请参阅 排查 Amazon CLI 错误

其他帮助

有关 Amazon CLI 问题的其他帮助,请访问 GitHub 上的 Amazon CLI 社区