文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribeCapacityReservations
搭配 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" } ] }
如需詳細資訊,請參閱 Amazon Elastic Compute Cloud Linux 執行個體使用者指南中的檢視容量保留。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeCapacityReservations
。
-
- PowerShell
-
- for 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
-
如需 API 詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考中的 DescribeCapacityReservations。
-
DescribeBundleTasks
DescribeCustomerGateways