

 AWS Cloud9 不再提供給新客戶。 AWS Cloud9 的現有客戶可以繼續正常使用該服務。[進一步了解](https://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/)

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

# Tags (標籤)
<a name="tags"></a>

標籤是您或 AWS 連接至 AWS 資源的標籤或屬性。每個標籤皆包含*索引鍵*與成對的*值*。您可以使用標籤來控制對 AWS Cloud9 資源的存取，如 *[IAM 使用者指南](https://docs.aws.amazon.com/IAM/latest/UserGuide/)*中的[使用 AWS 資源標籤控制存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html)中所述。標籤也可以幫助您管理帳單資訊，如[使用者定義的成本分配標籤](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/custom-tags.html)中所述。

當您[建立 an AWS Cloud9 EC2 開發環境](create-environment-main.md)時， AWS Cloud9 包含管理環境所需的特定系統標籤。系統標籤開頭為「**aws:**」。在此建立程序期間，您也可以新增自己的資源標籤。

建立環境之後，您可以檢視附加至環境的標籤、將新資源標籤新增至環境，或修改或移除您先前新增的標籤。您最多可以將 50 個使用者定義的標籤連接至 AWS Cloud9 環境。

使用下列一或多個方法檢視或更新標籤。
+ 在 [AWS Cloud9 主控台](https://console.aws.amazon.com/cloud9/)中，選取您感興趣的環境，然後選擇 **View Details (檢視詳細資訊)**。  
![\[檢視環境的詳細資訊。\]](http://docs.aws.amazon.com/zh_tw/cloud9/latest/user-guide/images/view-details.png)
+ 使用下列 AWS Cloud9 CLI 命令：[https://docs.aws.amazon.com/cli/latest/reference/cloud9/list-tags-for-resource.html](https://docs.aws.amazon.com/cli/latest/reference/cloud9/list-tags-for-resource.html)、 [https://docs.aws.amazon.com/cli/latest/reference/cloud9/tag-resource.html](https://docs.aws.amazon.com/cli/latest/reference/cloud9/tag-resource.html)和 [https://docs.aws.amazon.com/cli/latest/reference/cloud9/untag-resource.html](https://docs.aws.amazon.com/cli/latest/reference/cloud9/untag-resource.html)。
+ 使用下列 AWS Cloud9 API 動作：[ListTagsForResource](https://docs.aws.amazon.com/cloud9/latest/APIReference/API_ListTagsForResource.html)、[TagResource](https://docs.aws.amazon.com/cloud9/latest/APIReference/API_TagResource.html) 和 [UntagResource](https://docs.aws.amazon.com/cloud9/latest/APIReference/API_UntagResource.html)。

**警告**  
您使用 AWS Cloud9 上述方法建立或更新的標籤不會自動傳播到基礎資源。如需有關如何執行這項操作的資訊，請參閱下一節，[將標籤更新傳播至基礎資源](#tags-propagate)。

## 將標籤更新傳播至基礎資源
<a name="tags-propagate"></a>

當您使用 AWS Cloud9 CLI 命令或 API 動作來新增、修改或移除連接到 AWS Cloud9 環境的標籤時，這些變更不會自動傳播到基礎資源，例如 CloudFormation 堆疊、Amazon EC2 執行個體和 Amazon EC2 安全群組。您必須手動傳播這些變更。

若要更輕鬆地使用下列程序，您可以針對感興趣的環境取得其環境 ID。若您想要執行此操作，請遵循下列步驟：

1. 在 [AWS Cloud9 主控台](https://console.aws.amazon.com/cloud9/)中，選取所需環境，然後選擇 **View Details** (檢視詳細資訊)。

1. 尋找 **Environment ARN (環境 ARN)** 屬性並記錄環境 ID，其屬於「**environment:**」之後的環境 ARN 的一部分。

視您的標籤使用目的而定，您可能需要將標籤更新傳播至以下一或多個位置。

### 將標籤更新傳播至 CloudFormation 堆疊
<a name="propagating-tag-updates"></a>

**注意**  
當您更新 AWS CloudFormation 堆疊的標籤時，這些更新會自動傳播到與堆疊相關聯的 Amazon EC2 執行個體和 Amazon EC2 安全群組。

1. 導覽至 [CloudFormation 主控台](https://console.aws.amazon.com/cloudformation)。

1. 尋找並選擇與您感興趣的 AWS Cloud9 環境對應的堆疊。如果您已記錄環境 ID，您可以使用該 ID 來篩選環境。

1. 在 **Stack info (堆疊資訊)** 索引標籤的 **Tags (標籤)** 區段中，檢閱標籤清單。

1. 如果您需要更新標籤，請選擇頁面頂端附近的 **Update (更新)**，並依照指示進行操作。如需詳細資訊，請參閱 *[AWS CloudFormation 使用者指南](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/)*中的[直接更新堆疊](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-direct.html)。

您也可以使用 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-stacks.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-stacks.html) 和 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/update-stack.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/update-stack.html) CLI 命令來更新標籤。

### 將標籤更新傳播至 Amazon EC2 執行個體
<a name="w2aac33c30c15c13"></a>

1. 導覽至 [Amazon EC2](https://console.aws.amazon.com/ec2/home#Instances) 主控台。

1. 尋找並選取與您感興趣的 AWS Cloud9 環境對應的 Amazon EC2 執行個體。如果您先前已記錄環境 ID，您可以使用該 ID 來篩選環境。

1. 在 **Tags (標籤)** 索引標籤上，視需要檢視及更新標籤。

您也可以使用 [describe-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-tags.html)、[create-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html) 以及 [delete-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-tags.html) CLI 命令來更新標籤。

### 將標籤更新傳播至 Amazon EC2 安全群組
<a name="w2aac33c30c15c15"></a>

1. 導覽至 [Amazon EC2 安全群組](https://console.aws.amazon.com/ec2/home#SecurityGroups)主控台。

1. 尋找並選取與您感興趣的 AWS Cloud9 環境對應的安全群組。如果您先前已記錄環境 ID，您可以使用該 ID 來篩選環境。

1. 開啟 **Tags (標籤)** 索引標籤，視需要檢視及更新標籤。

您也可以使用 [describe-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-tags.html)、[create-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html) 以及 [delete-tags](https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-tags.html) CLI 命令來更新標籤。