搭CancelSpotInstanceRequests配 AWS 開發套件或 CLI 使用 - Amazon Elastic Compute Cloud

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

CancelSpotInstanceRequests配 AWS 開發套件或 CLI 使用

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

CLI
AWS CLI

取消競價型執行個體請求

此範例指令會取消 Spot 執行個體請求。

命令:

aws ec2 cancel-spot-instance-requests --spot-instance-request-ids sir-08b93456

輸出:

{ "CancelledSpotInstanceRequests": [ { "State": "cancelled", "SpotInstanceRequestId": "sir-08b93456" } ] }
PowerShell
適用的工具 PowerShell

範例 1:此範例會取消指定的 Spot 執行個體請求。

Stop-EC2SpotInstanceRequest -SpotInstanceRequestId sir-12345678

輸出:

SpotInstanceRequestId State --------------------- ----- sir-12345678 cancelled

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