

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

# 刪除堆疊
<a name="workingstacks-shutting"></a>

**重要**  
 AWS OpsWorks Stacks 此服務已於 2024 年 5 月 26 日終止，並已針對新客戶和現有客戶停用。我們強烈建議客戶盡快將其工作負載遷移至其他解決方案。如果您對遷移有任何疑問，請透過 [AWS re：Post](https://repost.aws/) 或透過 [AWS Premium Support](https://aws.amazon.com/support) 聯絡 AWS 支援 團隊。

您可以刪除不再需要的堆疊。只能刪除空的堆疊，您必須先刪除堆疊中所有執行個體、應用程式和 Layer。

**刪除堆疊**

1. 在 OpsWorks Stacks 儀表板上，選擇您要關閉和刪除的堆疊。

1. 在導覽窗格中，選擇**執行個體**。

1. 在 **Instances (執行個體)** 頁面上，選擇 **Stop all Instances (停止所有執行個體)**。  
![\[Instances section showing 1 total instance online, with "Stop All Instances" button highlighted.\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/images/stop_all_instances.png)

1. 執行個體停止後，針對 layer 中的每個執行個體，在**動作**欄中選擇**刪除**。出現確認提示時，請選擇 **Yes, Delete (是，刪除)**。  
![\[Confirmation dialog for deleting a stopped database instance, warning of data loss.\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/images/delete_instance.png)

1. 刪除所有執行個體後，在導覽窗格中，選擇 **Layers (Layer)**。

1. 在 **Layers (Layer)** 頁面上，為堆疊中的每個 layer，選擇 **delete (刪除)**。在 (刪除堆疊) 確認提示上，選擇 **Yes, Delete** (是的，請刪除)。  
![\[PHP App Server layer settings with options for Recipes, Network, EBS Volumes, and Security.\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/images/delete_layer.png)

1. 刪除所有 layer 後，在導覽窗格中，選擇 **Apps (應用程式)**。

1. 在**應用程式**頁面上，針對堆疊中的每個應用程式，選擇**動作**欄中的**刪除**。在 (刪除堆疊) 確認提示上，選擇 **Yes, Delete** (是的，請刪除)。  
![\[Apps page showing delete confirmation prompt for SimplePhp app with options to cancel or confirm.\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/images/delete_app.png)

1. 刪除所有應用程式後，在導覽窗格中，選擇 **Stack (堆疊)**。

1. 在 stack (堆疊) 頁面上，選擇 **Delete stack (刪除堆疊)**。在 (刪除堆疊) 確認提示上，選擇 **Yes, Delete** (是的，請刪除)。  
![\[Delete stack option circled in red on the ShortStack interface.\]](http://docs.aws.amazon.com/zh_tw/opsworks/latest/userguide/images/delete_stack.png)

## 刪除堆疊使用的其他 AWS 資源
<a name="w2ab1c14c51c33b9"></a>

您可以使用其他 AWS 資源搭配 OpsWorks Stacks 來建立和管理堆疊。當您刪除堆疊時，如果另一個堆疊未使用堆疊，且 Stacks OpsWorks 以外的資源未使用堆疊，請考慮也刪除使用堆疊的資源。以下是清理與堆疊搭配使用之外部 AWS 資源的建議原因。
+ 外部 AWS 資源可以繼續在您的 AWS 帳戶中產生費用。
+ Amazon S3 儲存貯體等資源可能包含個人識別、敏感或機密資訊。

**重要**  
請勿刪除其他的堆疊正在使用的資源。請注意，IAM 角色和安全群組是全域的，因此其他區域中的堆疊可能會使用這些相同的資源。

以下是堆疊使用的其他 AWS 資源，以及有關如何刪除這些資源的資訊連結。

服務角色和執行個體描述檔  
當您建立堆疊時，您可以指定 IAM 角色和執行個體描述檔，讓 OpsWorks Stacks 代表您建立允許的資源。 OpsWorks 如果您未選擇現有的角色和執行個體描述檔， 會為您建立角色和執行個體描述檔。為您 OpsWorks 建立的角色和執行個體描述檔`aws-opsworks-ec2-role`分別名為 `aws-opsworks-service-role`和 。如果您帳戶中沒有其他堆疊正在使用 IAM 角色和執行個體描述檔，則可以安全地刪除這些資源。如需有關如何刪除 IAM 角色和執行個體描述檔的資訊，請參閱《*IAM 使用者指南*》中的[刪除角色或執行個體描述](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html)檔。

Security groups (安全群組)  
在 OpsWorks Stacks 中，您可以在 layer 層級指定使用者定義的安全群組。您可以使用 Amazon EC2 主控台或 API 建立安全群組。堆疊和 layer 可以在其他區域中使用相同的安全群組，因為安全群組是全域通用。如果其他 AWS 資源未使用安全群組，您可以將其刪除。如需如何刪除安全群組的詳細資訊，請參閱《*Amazon EC2 使用者指南*》中的[刪除安全群組](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/working-with-security-groups.html#deleting-security-group)。

Amazon EBS 磁碟區  
在 OpsWorks Stacks 中，您可以在 layer 層級新增 EBS 磁碟區，並將它們連接到 layer 中的執行個體。您可以使用 Amazon EC2 服務主控台或 API 建立 EBS 磁碟區，然後將它們連接到 layer 層級的 OpsWorks Stacks 執行個體。EBS 磁碟區專屬的[可用區域](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html)。如果您不再使用特定區域和可用區域中堆疊裡的 EBS 磁碟區，您可以刪除。如需如何刪除 Amazon EBS 磁碟區的詳細資訊，請參閱《Amazon *Amazon EC2*[刪除 Amazon EBS 磁碟區](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-deleting-volume.html)。

Amazon Simple Storage Service (Amazon S3) 儲存貯體  
在 OpsWorks Stacks 中，您可以針對下列項目使用 Amazon S3 儲存貯體。傳遞至 Amazon S3 儲存貯體的內容可能包含客戶內容。如需移除敏感資料的詳細資訊，請參閱[如何清空 S3 儲存貯體？](https://docs.aws.amazon.com/AmazonS3/latest/userguide/empty-bucket.html)或[如何刪除 S3 儲存貯體？](https://docs.aws.amazon.com/AmazonS3/latest/userguide/delete-bucket.html)。  
+ 儲存應用程式程式碼
+ 儲存技術指南和配方
+ 如果您已在 CloudTrail Stacks 中啟用 CloudTrail 記錄，CloudTrail OpsWorks 日誌
+ 如果您已在 Stacks 中啟用 Amazon CloudWatch Logs OpsWorks 串流

彈性 IP 位址  
如果您已向 Stacks OpsWorks [註冊](https://docs.aws.amazon.com/opsworks/latest/userguide/resources-reg.html)[彈性 IP 地址](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html)，且不再需要彈性 IP 地址，則可以[釋出彈性 IP 地址](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html#using-instance-addressing-eips-releasing)。

Elastic Load Balancing 負載平衡器  
如果您不再需要與堆疊中的層搭配使用的 Elastic Load Balancing 傳統負載平衡器，則可以將其刪除。如需詳細資訊，請參閱[ Classic Load Balancers 使用者指南](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-getting-started.html#delete-load-balancer)中的「*刪除您的負載平衡器*」。

Amazon Relational Database Service (Amazon RDS) 執行個體  
如果您已向 Stacks [註冊](https://docs.aws.amazon.com/opsworks/latest/userguide/resources-reg.html) Amazon RDS 資料庫 OpsWorks (DB) 執行個體，且不再需要這些執行個體，則可以刪除資料庫執行個體。如需如何刪除資料庫執行個體的詳細資訊，請參閱《*Amazon RDS 使用者指南*》中的[刪除資料庫執行個體](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_DeleteInstance.html)。

Amazon Elastic Container Service (Amazon ECS) 叢集  
如果您的堆疊包含 ECS 叢集層，而且您不再使用以 layer 註冊的 ECS 叢集，您可以刪除 ECS 叢集。如需如何刪除 ECS 叢集的詳細資訊，請參閱《*Amazon ECS 開發人員指南*》中的[刪除叢集](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/delete_cluster.html)。