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

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

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

PurchaseScheduledInstances与 a 一起使用 CLI

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

CLI
AWS CLI

购买计划实例

此示例购买了计划实例。

命令:

aws ec2 purchase-scheduled-instances --purchase-requests file://purchase-request.json

购买请求.json:

[ { "PurchaseToken": "eyJ2IjoiMSIsInMiOjEsImMiOi...", "InstanceCount": 1 } ]

输出:

{ "ScheduledInstanceSet": [ { "AvailabilityZone": "us-west-2b", "ScheduledInstanceId": "sci-1234-1234-1234-1234-123456789012", "HourlyPrice": "0.095", "CreateDate": "2016-01-25T21:43:38.612Z", "Recurrence": { "OccurrenceDaySet": [ 1 ], "Interval": 1, "Frequency": "Weekly", "OccurrenceRelativeToEnd": false, "OccurrenceUnit": "" }, "Platform": "Linux/UNIX", "TermEndDate": "2017-01-31T09:00:00Z", "InstanceCount": 1, "SlotDurationInHours": 32, "TermStartDate": "2016-01-31T09:00:00Z", "NetworkPlatform": "EC2-VPC", "TotalScheduledInstanceHours": 1696, "NextSlotStartTime": "2016-01-31T09:00:00Z", "InstanceType": "c4.large" } ] }
PowerShell
用于 PowerShell

示例 1:此示例购买了计划实例。

$request = New-Object Amazon.EC2.Model.PurchaseRequest $request.InstanceCount = 1 $request.PurchaseToken = "eyJ2IjoiMSIsInMiOjEsImMiOi..." New-EC2ScheduledInstancePurchase -PurchaseRequest $request

输出:

AvailabilityZone : us-west-2b CreateDate : 1/25/2016 1:43:38 PM HourlyPrice : 0.095 InstanceCount : 1 InstanceType : c4.large NetworkPlatform : EC2-VPC NextSlotStartTime : 1/31/2016 1:00:00 AM Platform : Linux/UNIX PreviousSlotEndTime : Recurrence : Amazon.EC2.Model.ScheduledInstanceRecurrence ScheduledInstanceId : sci-1234-1234-1234-1234-123456789012 SlotDurationInHours : 32 TermEndDate : 1/31/2017 1:00:00 AM TermStartDate : 1/31/2016 1:00:00 AM TotalScheduledInstanceHours : 1696