Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan PurchaseHostReservation
dengan CLI
Contoh kode berikut menunjukkan cara menggunakanPurchaseHostReservation
.
- CLI
-
- AWS CLI
-
Untuk membeli Reservasi Tuan Rumah Khusus
Contoh ini membeli penawaran Reservasi Host Khusus yang ditentukan untuk Host Khusus yang ditentukan di akun Anda.
Perintah:
aws ec2 purchase-host-reservation --offering-id
hro-03f707bf363b6b324
--host-id-seth-013abcd2a00cbd123
Output:
{ "TotalHourlyPrice": "1.499", "Purchase": [ { "HourlyPrice": "1.499", "InstanceFamily": "m4", "PaymentOption": "NoUpfront", "HostIdSet": [ "h-013abcd2a00cbd123" ], "HostReservationId": "hr-0d418a3a4ffc669ae", "UpfrontPrice": "0.000", "Duration": 31536000 } ], "TotalUpfrontPrice": "0.000" }
-
Untuk detail API, lihat PurchaseHostReservation
di Referensi AWS CLI Perintah.
-
- PowerShell
-
- Alat untuk PowerShell V4
-
Contoh 1: Contoh ini membeli reservasi yang menawarkan hro-0c1f23456789d0ab dengan konfigurasi yang cocok dengan Host Khusus Anda h-01e23f4cd567890f1
New-EC2HostReservation -OfferingId hro-0c1f23456789d0ab HostIdSet h-01e23f4cd567890f1
Output:
ClientToken : CurrencyCode : Purchase : {hr-0123f4b5d67bedc89} TotalHourlyPrice : 1.307 TotalUpfrontPrice : 0.000
-
Untuk detail API, lihat PurchaseHostReservationdi Referensi Alat AWS untuk PowerShell Cmdlet (V4).
-
- Alat untuk PowerShell V5
-
Contoh 1: Contoh ini membeli reservasi yang menawarkan hro-0c1f23456789d0ab dengan konfigurasi yang cocok dengan Host Khusus Anda h-01e23f4cd567890f1
New-EC2HostReservation -OfferingId hro-0c1f23456789d0ab HostIdSet h-01e23f4cd567890f1
Output:
ClientToken : CurrencyCode : Purchase : {hr-0123f4b5d67bedc89} TotalHourlyPrice : 1.307 TotalUpfrontPrice : 0.000
-
Untuk detail API, lihat PurchaseHostReservationdi Referensi Alat AWS untuk PowerShell Cmdlet (V5).
-