

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

# 自訂資料識別符
<a name="CWL-custom-data-identifiers"></a>

**Topics**
+ [什麼是 SNS 自訂資料識別符？](#what-are-custom-data-identifiers)
+ [自訂資料識別符的限制](#custom-data-identifiers-constraints)
+ [在主控台中使用自訂資料識別符](#using-custom-data-identifiers-console)
+ [在您的資料保護政策中使用自訂資料識別符](#using-custom-data-identifiers)

## 什麼是 SNS 自訂資料識別符？
<a name="what-are-custom-data-identifiers"></a>

自訂資料識別符 (CDI) 可讓您定義自訂的規則運算式，以用於資料保護政策。使用自訂資料識別符就可以鎖定[受管資料識別符](CWL-managed-data-identifiers.md)無法提供的企業特定個人身分識別資訊 (PII) 使用案例。例如，您可以使用自訂資料識別符來尋找公司專屬員工 ID。自訂資料識別符可與受管資料識別符搭配使用。

## 自訂資料識別符的限制
<a name="custom-data-identifiers-constraints"></a>

CloudWatch Logs 自訂資料識別符有下列限制：
+ 每個資料保護政策最多可支援 10 個自訂資料識別符。
+ 自訂資料識別符名稱的長度上限為 128 個字元。支援的字元如下：
  + 英數字：(a-zA-Z0-9)
  + 符號：( '\$1' \$1 '-' )
+ RegEx 的長度上限為 200 個字元。支援的字元如下：
  + 英數字：(a-zA-Z0-9)
  + 符號：( '\$1' \$1 '\$1' \$1 '=' \$1 '@' \$1'/' \$1 ';' \$1 ',' \$1 '-' \$1 ' ' )
  + RegEx 保留字元：( '^' \$1 '\$1' \$1 '?' \$1 '[' \$1 ']' \$1 '\$1' \$1 '\$1' \$1 '\$1' \$1 '\$1\$1' \$1 '\$1' \$1 '\$1' \$1 '.' ) 
+ 自訂資料識別符的名稱不可與受管資料識別符的名稱相同。
+ 您可以在帳戶層級資料保護政策或日誌群組層級資料保護政策中指定自訂資料識別符。與受管資料識別符類似，帳戶層級政策中定義的自訂資料識別符可與日誌群組層級政策中定義的自訂資料識別符搭配使用。

## 在主控台中使用自訂資料識別符
<a name="using-custom-data-identifiers-console"></a>

當您使用 CloudWatch 主控台建立或編輯資料保護政策時，若要指定自訂資料識別符，您只需輸入資料識別符的名稱和規則表達式。例如，您可以**Employee\$1ID**輸入 **EmployeeID-\$1d\$19\$1**做為名稱和規則表達式。此規則表達式會在 之後偵測和遮罩具有九個數字的日誌事件`EmployeeID-`。例如 `EmployeeID-123456789`

## 在您的資料保護政策中使用自訂資料識別符
<a name="using-custom-data-identifiers"></a>

如果您使用 AWS CLI 或 AWS API 來指定自訂資料識別符，則需要在用來定義資料保護政策的 JSON 政策中包含資料識別符名稱和規則表達式。下列資料保護政策會偵測和遮罩帶有公司特定員工 IDs日誌事件。

1. 在您的資料保護政策內建立 `Configuration` 區塊。

1. 輸入自訂資料識別符的 `Name`。例如 **EmployeeId**。

1. 輸入自訂資料識別符的 `Regex`。例如 **EmployeeID-\$1d\$19\$1**。此規則表達式將符合包含 之後有九位數`EmployeeID-`的日誌事件`EmployeeID-`。例如 `EmployeeID-123456789` 

1. 請參閱政策聲明中的下列自訂資料識別符。

   ```
   {
       "Name": "example_data_protection_policy",
       "Description": "Example data protection policy with custom data identifiers",
       "Version": "2021-06-01",
       "Configuration": {
         "CustomDataIdentifier": [
           {"Name": "EmployeeId", "Regex": "EmployeeId-\\d{9}"}   
         ]
       },
       "Statement": [
           {
               "Sid": "audit-policy",
               "DataIdentifier": [
                   "EmployeeId"
               ],
               "Operation": {
                   "Audit": {
                       "FindingsDestination": {
                           "S3": {
                               "Bucket": "EXISTING_BUCKET"
                           }
                       }
                   }
               }
           },
           {
               "Sid": "redact-policy",
               "DataIdentifier": [
               "EmployeeId"
               ],
               "Operation": {
                   "Deidentify": {
                       "MaskConfig": {
                       }
                   }
               }
           }
       ]
   }
   ```

1. (選用) 視需要繼續將其他**自訂資料識別符**新增至 `Configuration` 區塊。資料保護政策目前最多可支援 10 個自訂資料識別符。