DescribeHostReservationOfferings 搭配 使用 CLI - Amazon Elastic Compute Cloud

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DescribeHostReservationOfferings 搭配 使用 CLI

下列程式碼範例示範如何使用 DescribeHostReservationOfferings

CLI
AWS CLI

描述專用主機保留方案

此範例說明可供購買的 M4 執行個體系列的專用主機預留。

命令:

aws ec2 describe-host-reservation-offerings --filter Name=instance-family,Values=m4

輸出:

{ "OfferingSet": [ { "HourlyPrice": "1.499", "OfferingId": "hro-03f707bf363b6b324", "InstanceFamily": "m4", "PaymentOption": "NoUpfront", "UpfrontPrice": "0.000", "Duration": 31536000 }, { "HourlyPrice": "1.045", "OfferingId": "hro-0ef9181cabdef7a02", "InstanceFamily": "m4", "PaymentOption": "NoUpfront", "UpfrontPrice": "0.000", "Duration": 94608000 }, { "HourlyPrice": "0.714", "OfferingId": "hro-04567a15500b92a51", "InstanceFamily": "m4", "PaymentOption": "PartialUpfront", "UpfrontPrice": "6254.000", "Duration": 31536000 }, { "HourlyPrice": "0.484", "OfferingId": "hro-0d5d7a9d23ed7fbfe", "InstanceFamily": "m4", "PaymentOption": "PartialUpfront", "UpfrontPrice": "12720.000", "Duration": 94608000 }, { "HourlyPrice": "0.000", "OfferingId": "hro-05da4108ca998c2e5", "InstanceFamily": "m4", "PaymentOption": "AllUpfront", "UpfrontPrice": "23913.000", "Duration": 94608000 }, { "HourlyPrice": "0.000", "OfferingId": "hro-0a9f9be3b95a3dc8f", "InstanceFamily": "m4", "PaymentOption": "AllUpfront", "UpfrontPrice": "12257.000", "Duration": 31536000 } ] }
PowerShell
適用於 的工具 PowerShell

範例 1:此範例說明可供購買給指定篩選條件 'instance-family' 的專用主機保留,其中 PaymentOption 'NoUpfront'

Get-EC2HostReservationOffering -Filter @{Name="instance-family";Values="m4"} | Where-Object PaymentOption -eq NoUpfront

輸出:

CurrencyCode : Duration : 94608000 HourlyPrice : 1.307 InstanceFamily : m4 OfferingId : hro-0c1f234567890d9ab PaymentOption : NoUpfront UpfrontPrice : 0.000 CurrencyCode : Duration : 31536000 HourlyPrice : 1.830 InstanceFamily : m4 OfferingId : hro-04ad12aaaf34b5a67 PaymentOption : NoUpfront UpfrontPrice : 0.000

如需開發人員指南和程式碼範例的完整清單 AWS SDK,請參閱 使用 建立 Amazon EC2 資源 AWS SDK。本主題也包含有關入門的資訊,以及先前SDK版本的詳細資訊。