

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将 `StopDeployment` 与 CLI 配合使用
<a name="codedeploy_example_codedeploy_StopDeployment_section"></a>

以下代码示例演示如何使用 `StopDeployment`。

------
#### [ CLI ]

**AWS CLI**  
**尝试停止部署**  
以下`stop-deployment`示例尝试停止与用户 AWS 账户关联的正在进行的部署。  
aws deploy stop-deployment --deployment-id d-A1B2C3111  
输出：  

```
{
    "status": "Succeeded",
    "statusMessage": "No more commands will be scheduled for execution in the deployment instances"
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[StopDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/stop-deployment.html)*中的。

------
#### [ PowerShell ]

**适用于 PowerShell V4 的工具**  
**示例 1：此示例尝试停止具有指定部署 ID 的部署。**  

```
Stop-CDDeployment -DeploymentId d-LJQNREYEX
```
**输出**：  

```
Status     StatusMessage
------     -------------
Pending    Stopping Pending. Stopping to schedule commands in the deployment instances
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [StopDeployment](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例尝试停止具有指定部署 ID 的部署。**  

```
Stop-CDDeployment -DeploymentId d-LJQNREYEX
```
**输出**：  

```
Status     StatusMessage
------     -------------
Pending    Stopping Pending. Stopping to schedule commands in the deployment instances
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [StopDeployment](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------