AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭DescribeScheduledInstanceAvailability
配 AWS SDK或使用 CLI
下列程式碼範例會示範如何使用DescribeScheduledInstanceAvailability
。
- CLI
-
- AWS CLI
-
描述可用的排程
此範例說明從指定日期開始,每週在星期日發生的排程。
命令:
aws ec2 describe-scheduled-instance-availability --recurrence
Frequency=Weekly,Interval=1,OccurrenceDays=[1]
--first-slot-start-time-rangeEarliestTime=2016-01-31T00:00:00Z,LatestTime=2016-01-31T04:00:00Z
輸出:
{ "ScheduledInstanceAvailabilitySet": [ { "AvailabilityZone": "us-west-2b", "TotalScheduledInstanceHours": 1219, "PurchaseToken": "eyJ2IjoiMSIsInMiOjEsImMiOi...", "MinTermDurationInDays": 366, "AvailableInstanceCount": 20, "Recurrence": { "OccurrenceDaySet": [ 1 ], "Interval": 1, "Frequency": "Weekly", "OccurrenceRelativeToEnd": false }, "Platform": "Linux/UNIX", "FirstSlotStartTime": "2016-01-31T00:00:00Z", "MaxTermDurationInDays": 366, "SlotDurationInHours": 23, "NetworkPlatform": "EC2-VPC", "InstanceType": "c4.large", "HourlyPrice": "0.095" }, ... ] }
若要縮小結果範圍,您可以新增指定作業系統、網路和執行個體類型的篩選器。
命令:
-篩選器名稱 = 平台,值 =Linux/ 名稱 = 網路平台,值 = 名稱 = 執行個體類型,值 =C4UNIX. 大 EC2 VPC
-
如需詳API細資訊,請參閱AWS CLI 指令參考DescribeScheduledInstanceAvailability
中的。
-
- PowerShell
-
- 用於的工具 PowerShell
-
範例 1:此範例說明從指定日期開始,每週在星期日發生的排程。
Get-EC2ScheduledInstanceAvailability -Recurrence_Frequency Weekly -Recurrence_Interval 1 -Recurrence_OccurrenceDay 1 -FirstSlotStartTimeRange_EarliestTime 2016-01-31T00:00:00Z -FirstSlotStartTimeRange_LatestTime 2016-01-31T04:00:00Z
輸出:
AvailabilityZone : us-west-2b AvailableInstanceCount : 20 FirstSlotStartTime : 1/31/2016 8:00:00 AM HourlyPrice : 0.095 InstanceType : c4.large MaxTermDurationInDays : 366 MinTermDurationInDays : 366 NetworkPlatform : EC2-VPC Platform : Linux/UNIX PurchaseToken : eyJ2IjoiMSIsInMiOjEsImMiOi... Recurrence : Amazon.EC2.Model.ScheduledInstanceRecurrence SlotDurationInHours : 23 TotalScheduledInstanceHours : 1219 ...
範例 2:若要縮小結果範圍,您可以新增篩選條件,例如作業系統、網路和執行個體類型。
-Filter @{ Name="platform";Values="Linux/UNIX" },@{ Name="network-platform";Values="EC2-VPC" },@{ Name="instance-type";Values="c4.large" }
-
如需詳API細資訊,請參閱AWS Tools for PowerShell 指令程DescribeScheduledInstanceAvailability式參考中的。
-
DescribeRouteTables
DescribeScheduledInstances