将 ReleaseHosts 与 CLI 配合使用 - AWS SDK 代码示例

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

ReleaseHosts 与 CLI 配合使用

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

CLI
AWS CLI

从账户中释放专属主机

从您的账户中释放专属主机。必须先停止或终止主机上的实例,然后才能释放主机。

命令:

aws ec2 release-hosts --host-id=h-0029d6e3cacf1b3da

输出:

{ "Successful": [ "h-0029d6e3cacf1b3da" ], "Unsuccessful": [] }
  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ReleaseHosts

PowerShell
Tools for PowerShell V4

示例 1:此示例释放给定的主机 ID 0badafd1dcb2f3456

Remove-EC2Host -HostId h-0badafd1dcb2f3456

输出

Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2Host (ReleaseHosts)" on target "h-0badafd1dcb2f3456". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y Successful Unsuccessful ---------- ------------ {h-0badafd1dcb2f3456} {}
  • 有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V4)》中的 ReleaseHosts

Tools for PowerShell V5

示例 1:此示例释放给定的主机 ID 0badafd1dcb2f3456

Remove-EC2Host -HostId h-0badafd1dcb2f3456

输出

Confirm Are you sure you want to perform this action? Performing the operation "Remove-EC2Host (ReleaseHosts)" on target "h-0badafd1dcb2f3456". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y Successful Unsuccessful ---------- ------------ {h-0badafd1dcb2f3456} {}
  • 有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V5)》中的 ReleaseHosts