

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

# 將標籤新增至 Amazon ECS 資源
<a name="tag-resources-console"></a>

您可以標記新的或現有的任務、服務、任務定義和叢集。如需有關標記容器執行個體的資訊，請參閱[將標籤新增至 Amazon ECS 的 Amazon EC2 容器執行個體](instance-details-tags.md)。

**警告**  
請勿在標籤中加入個人身分識別資訊 (PII) 或其他機密或敏感資訊。許多 AWS 服務都可以存取標籤，包括帳單。標籤不適用於私有或敏感資料。

建立資源時，您可以使用以下資源來指定標籤。


|  任務  |  主控台  |  AWS CLI  |  API 動作  | 
| --- | --- | --- | --- | 
|  執行一或多個任務。  |  [將應用程式作為 Amazon ECS 任務執行](standalone-task-create.md)  |  [run-task](https://docs.aws.amazon.com/cli/latest/reference/ecs/run-task.html)  |  [RunTask](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html)  | 
|  建立服務。  |  [建立 Amazon ECS 滾動更新部署](create-service-console-v2.md)  |  [create-service](https://docs.aws.amazon.com/cli/latest/reference/ecs/create-service.html)  |  [CreateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html)  | 
|  建立任務集。  |  [使用第三方控制器部署 Amazon ECS 服務](deployment-type-external.md)  |  [create-task-set](https://docs.aws.amazon.com/cli/latest/reference/ecs/create-task-set.html)  |  [CreateTaskSet](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateTaskSet.html)  | 
|  註冊任務定義。  | [使用主控台建立 Amazon ECS 任務定義](create-task-definition.md) |  [register-task-definition](https://docs.aws.amazon.com/cli/latest/reference/ecs/register-task-definition.html)  |  [RegisterTaskDefinition](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RegisterTaskDefinition.html)  | 
|  建立叢集。  |  [為 Fargate 工作負載建立 Amazon ECS 叢集](create-cluster-console-v2.md)   |  [create-cluster](https://docs.aws.amazon.com/cli/latest/reference/ecs/create-cluster.html)  |  [CreateCluster](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateCluster.html)  | 
|  執行一或多個容器執行個體。  |  [啟動 Amazon ECS Linux 容器執行個體](launch_container_instance.md)  |  [run-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html)  |  [RunInstances](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html)  | 
|  為 Amazon ECS 受管執行個體建立容量提供者。  |  [為 Amazon ECS 受管執行個體建立容量提供者](create-capacity-provider-managed-instances.md)  |  [create-capacity-provider](https://docs.aws.amazon.com/cli/latest/reference/ecs/create-capacity-provider.html)  |  [CreateCapacityProvider](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateCapacityProvider.html)  | 

## 將標籤新增至現有資源 (Amazon ECS 主控台)
<a name="adding-or-deleting-tags"></a>

您可直接從資源的頁面新增或刪除與叢集、服務、任務和任務定義相關聯的標籤。

**修改個別資源的標籤**

1. 開啟主控台，網址為 [https://console.aws.amazon.com/ecs/v2](https://console.aws.amazon.com/ecs/v2)。

1. 從導覽列中，選取要 AWS 區域 使用的 。

1. 在導覽窗格中，選取資源類型 (例如，**Clusters (叢集)**)。

1. 從資源清單選取資源，選擇 **Tags** (標籤) 索引標籤，然後選擇 **Manage tags** (管理標籤)。

1. 設定標籤。

   [新增標籤] 選擇**新增標籤**，然後執行下列操作︰
   + 在**索引鍵**中，輸入索引鍵名稱。
   + 在**值**欄位中，輸入金鑰值。

1. 選擇**儲存**。

## 將標籤新增至現有資源 (AWS CLI)
<a name="tag-resources-api-sdk"></a>

您可以使用 或 AWS CLI API 新增或覆寫一或多個標籤。

**注意**  
您可以使用雙堆疊服務端點，透過 IPv4 和 IPv6 AWS CLI從 、 SDKs 和 Amazon ECS API 與 Amazon ECS 互動。如需詳細資訊，請參閱[使用 Amazon ECS 雙堆疊端點](dual-stack-endpoint.md)。
+ AWS CLI - [tag-resource](https://docs.aws.amazon.com/cli/latest/reference/ecs/tag-resource.html)
+ API 動作：[TagResource](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TagResource.html)