

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

# 管理行為圖表的標籤
<a name="graph-tags"></a>

標籤是可選的標籤，您可以定義並指派給 AWS 資源，包括特定類型的 Detective 資源。標籤可協助您以不同的方式識別、分類及管理資源，例如依用途、擁有者、環境或其他條件。例如，您可以使用標籤來套用原則、分配成本、區分資源版本，或識別支援特定合規性需求或工作流程的資源。

您可以將標籤指派給您的行為圖表。然後，您可以使用IAM策略中的標籤值來管理對 Detective 中行為圖函數的存取。請參閱 [基於 Detective 行為圖表標籤的授權](security_iam_service-with-iam.md#security_iam_service-with-iam-tags)。

您也可以使用標籤作為成本報告的工具。例如，若要追蹤與安全性相關的成本，您可以將相同的標籤指派給 Detective 行為圖表、 AWS Security Hub CSPM 中樞資源和 Amazon GuardDuty 偵測器。然後 AWS Cost Explorer，您可以在中搜尋該標籤，以查看這些資源中成本的合併檢視。

## 檢視行為圖的標籤
<a name="graph-tags-list"></a>

您可以從**一般**頁面管理行為圖表的標籤。

------
#### [ Console ]

**若要檢視指派給行為圖表的標籤清單**

1. 前往 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 開啟 Amazon Detective 主控台。

1. 在導覽窗格中，於 **Settings (設定)** 下選擇 **General (一般)**。

------
#### [ Detective API, AWS CLI ]

您可以使用 Detective API 或 AWS Command Line Interface 取得行為圖的標籤清單。

**若要取得行為圖的標籤清單 (DetectiveAPI, AWS CLI)**
+ **DetectiveAPI：**使用[https://docs.aws.amazon.com/detective/latest/APIReference/API_ListTagsForResource.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListTagsForResource.html)操作。您必須提供您ARN的行為圖。
+ **AWS CLI：**在命令列中執行 `list-tags-for-resource` 命令。

  ```
  aws detective list-tags-for-resource --resource-arn <behavior graph ARN>
  ```

  **範例**

  ```
  aws detective list-tags-for-resource --resource-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

------

## 將標籤新增至行為圖
<a name="graph-tags-add"></a>

------
#### [ Console ]

從**一般**頁面的標籤清單中，您可以將標籤值新增至行為圖表。

**若要將標籤新增至行為圖表**

1. 選擇 **Add new tag (新增標籤)**。

1. 針對**金鑰**，輸入標籤的名稱。

1. 針對**值**，輸入標籤值。

------
#### [ Detective API, AWS CLI ]

您可以使用 Detective API 或將標籤值新增 AWS CLI 至您的行為圖表。

**若要將標籤新增至行為圖表 (DetectiveAPI， AWS CLI)**
+ **DetectiveAPI：**使用[https://docs.aws.amazon.com/detective/latest/APIReference/API_TagResource.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_TagResource.html)操作。您可以提供行為圖ARN和要加入的標籤值。
+ **AWS CLI**：在命令列中執行 `tag-resource` 命令。

  ```
  aws-detective tag-resource --aws detective tag-resource --resource-arn <behavior graph ARN> --tags '{"TagName":"TagValue"}'
  ```

  **範例**

  ```
  aws detective tag-resource --resource-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234 --tags '{"Department":"Finance"}'
  ```

------

## 從行為圖中移除標籤
<a name="graph-tags-remove"></a>

------
#### [ Console ]

若要從**一般**頁面的清單中移除標記，請選擇該標記的**移除**選項。

------
#### [ Detective API, AWS CLI ]

您可以使用 Detective API 或從行為圖中移除標籤值。 AWS CLI 

**若要從行為圖中移除標籤 (DetectiveAPI, AWS CLI)**
+ **DetectiveAPI：**使用[https://docs.aws.amazon.com/detective/latest/APIReference/API_UntagResource.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_UntagResource.html)操作。您可以提供行為圖ARN，以及要移除的標籤名稱。
+ **AWS CLI**：在命令列中執行 `untag-resource` 命令。

  ```
  aws detective untag-resource --resource-arn <behavior graph ARN> --tag-keys "TagName"
  ```

  **範例**

  ```
  aws detective untag-resource --resource-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234 --tag-keys "Department"
  ```

------