DescribeCapacityReservations与 a 一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

DescribeCapacityReservations与 a 一起使用 CLI

以下代码示例演示如何使用 DescribeCapacityReservations

CLI
AWS CLI

示例 1:描述您的一个或多个容量预留

以下describe-capacity-reservations示例显示了有关您在当前 AWS 地区的所有容量预留的详细信息。

aws ec2 describe-capacity-reservations

输出:

{ "CapacityReservations": [ { "CapacityReservationId": "cr-1234abcd56EXAMPLE ", "EndDateType": "unlimited", "AvailabilityZone": "eu-west-1a", "InstanceMatchCriteria": "open", "Tags": [], "EphemeralStorage": false, "CreateDate": "2019-08-16T09:03:18.000Z", "AvailableInstanceCount": 1, "InstancePlatform": "Linux/UNIX", "TotalInstanceCount": 1, "State": "active", "Tenancy": "default", "EbsOptimized": true, "InstanceType": "a1.medium" }, { "CapacityReservationId": "cr-abcdEXAMPLE9876ef ", "EndDateType": "unlimited", "AvailabilityZone": "eu-west-1a", "InstanceMatchCriteria": "open", "Tags": [], "EphemeralStorage": false, "CreateDate": "2019-08-07T11:34:19.000Z", "AvailableInstanceCount": 3, "InstancePlatform": "Linux/UNIX", "TotalInstanceCount": 3, "State": "cancelled", "Tenancy": "default", "EbsOptimized": true, "InstanceType": "m5.large" } ] }

示例 2:描述您的一个或多个容量预留

以下describe-capacity-reservations示例显示了有关指定容量预留的详细信息。

aws ec2 describe-capacity-reservations \ --capacity-reservation-ids cr-1234abcd56EXAMPLE

输出:

{ "CapacityReservations": [ { "CapacityReservationId": "cr-1234abcd56EXAMPLE", "EndDateType": "unlimited", "AvailabilityZone": "eu-west-1a", "InstanceMatchCriteria": "open", "Tags": [], "EphemeralStorage": false, "CreateDate": "2019-08-16T09:03:18.000Z", "AvailableInstanceCount": 1, "InstancePlatform": "Linux/UNIX", "TotalInstanceCount": 1, "State": "active", "Tenancy": "default", "EbsOptimized": true, "InstanceType": "a1.medium" } ] }

有关更多信息,请参阅《适用于 Linux 实例的 Amazon 弹性计算云用户指南》中的查看容量预留

PowerShell
用于 PowerShell

示例 1:此示例描述了您为该地区预留的一个或多个容量

Get-EC2CapacityReservation -Region eu-west-1

输出:

AvailabilityZone : eu-west-1b AvailableInstanceCount : 2 CapacityReservationId : cr-0c1f2345db6f7cdba CreateDate : 3/28/2019 9:29:41 AM EbsOptimized : True EndDate : 1/1/0001 12:00:00 AM EndDateType : unlimited EphemeralStorage : False InstanceMatchCriteria : open InstancePlatform : Windows InstanceType : m4.xlarge State : active Tags : {} Tenancy : default TotalInstanceCount : 2