

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](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 ]

**Tools for 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 參考 (V4)》**中的 [StopDeployment](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for 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 參考 (V5)》**中的 [StopDeployment](https://docs.aws.amazon.com/powershell/v5/reference)。

------