

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

# 在 Security Lake 中建立具有資料存取權的訂閱者
<a name="create-subscriber-data-access"></a>

選擇下列其中一種存取方法，以建立可存取目前 中資料的訂閱者 AWS 區域。

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

1. 開啟位於 https：//[https://console.aws.amazon.com/securitylake/](https://console.aws.amazon.com/securitylake/) 的 Security Lake 主控台。

1. 使用頁面右上角的選擇 AWS 區域 器，選取您要建立訂閱者的區域。

1. 在導覽窗格中，選擇**訂閱者**。

1. 在**訂閱者**頁面上，選擇**建立訂閱者**。

1. 如需**訂閱者詳細資訊**，請輸入**訂閱者名稱**和選用的**描述**。

   **區域**會自動填入為您目前選取的 AWS 區域 區域，且無法修改。

1. 針對**日誌和事件來源**，選擇訂閱者有權使用的來源。

1. 針對**資料存取方法**，選擇 **S3** 為訂閱者設定資料存取。

1. 對於**訂閱者憑證**，請提供訂閱者的 AWS 帳戶 ID 和[外部 ID](https://docs.aws.amazon.com//security-lake/latest/userguide/prereqs-creating-subscriber.html#subscriber-external-id)。

1. （選用） 如需**通知詳細資訊**，如果您希望 Security Lake 建立訂閱者可以輪詢物件通知的 Amazon SQS 佇列，請選取 **SQS 佇列**。如果您希望 Security Lake 透過 EventBridge 將通知傳送至 HTTPS 端點，請選取**訂閱端點**。

   如果您選取**訂閱端點**，也請執行下列動作：

   1. 輸入**訂閱端點**。有效端點格式的範例包括 **http://example.com**。您也可以選擇性地提供 **HTTPS 金鑰名稱**和 **HTTPS 金鑰值**。

   1. 針對**服務存取**，建立新的 IAM 角色或使用現有的 IAM 角色，提供 EventBridge 叫用 API 目的地的許可，並將物件通知傳送至正確的端點。

      如需建立新的 IAM 角色的資訊，請參閱[建立 IAM 角色以叫用 EventBridge API 目的地](https://docs.aws.amazon.com//security-lake/latest/userguide/prereqs-creating-subscriber.html#iam-role-subscriber)。

1. （選用） 針對**標籤**，輸入最多 50 個要指派給訂閱者的標籤。

   *標籤*是您可以定義並指派給特定資源類型的標籤 AWS 。每個標籤都是由必要的標籤索引鍵和選用的標籤值所組成。標籤可協助您以不同的方式識別、分類和管理資源。如需詳細資訊，請參閱 [標記 Security Lake 資源](tagging-resources.md)。

1. 選擇**建立**。

------
#### [ API ]

若要以程式設計方式建立具有資料存取權的訂閱者，請使用 Security Lake API 的 [CreateSubscriber](https://docs.aws.amazon.com/security-lake/latest/APIReference/API_CreateSubscriber.html) 操作。如果您使用的是 AWS Command Line Interface (AWS CLI)，請執行 [create-subscriber](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/securitylake/create-subscriber.html) 命令。

在您的請求中，使用這些參數為訂閱者指定下列設定：
+ 針對 `sources`，指定您希望訂閱者存取的每個來源。
+ 針對 `subscriberIdentity`，指定訂閱者用來存取來源資料 AWS 的帳戶 ID 和外部 ID。
+ 針對 `subscriber-name`，指定訂閱者的名稱。
+ 對於 `accessTypes`，請指定 `S3`。

**範例 1**

下列範例會建立具有目前 AWS 區域中資料存取權的 AWS 訂閱者，以取得來源的指定訂閱者身分。

```
$ aws securitylake create-subscriber \ 
--subscriber-identity {"accountID": 1293456789123,"externalId": 123456789012} \
--sources [{"awsLogSource": {"sourceName": VPC_FLOW, "sourceVersion": 2.0}}] \
--subscriber-name subscriber name \
--access-types S3
```

**範例 2**

下列範例會為自訂來源的指定訂閱者身分建立可存取目前 AWS 區域中資料的訂閱者。

```
$ aws securitylake create-subscriber \ 
--subscriber-identity {"accountID": 1293456789123,"externalId": 123456789012} \
--sources [{"customLogSource": {"sourceName": custom-source-name, "sourceVersion": 2.0}}] \
--subscriber-name subscriber name
--access-types S3
```

上述範例已針對 Linux、macOS 或 Unix 進行格式化，並使用反斜線 (\$1) 換行字元來改善可讀性。

（選用） 建立訂閱者之後，請使用 [CreateSubscriberNotification](https://docs.aws.amazon.com/security-lake/latest/APIReference/API_CreateSubscriberNotification.html) 操作來指定如何在將新資料寫入資料湖時通知訂閱者，以取得您希望訂閱者存取的來源。如果您使用的是 AWS Command Line Interface (AWS CLI)，請執行 [create-subscriber-notification](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/securitylake/create-subscriber-notification.html) 命令。
+ 若要覆寫預設通知方法 (HTTPS 端點） 並建立 Amazon SQS 佇列，請指定`sqsNotificationConfiguration`參數的值。
+ 如果您偏好使用 HTTPS 端點傳送通知，請指定`httpsNotificationConfiguration`參數的值。
+ 針對 `targetRoleArn` 欄位，指定您建立用來叫用 EventBridge API 目的地之 IAM 角色的 ARN。

```
$ aws securitylake create-subscriber-notification \
--subscriber-id "12345ab8-1a34-1c34-1bd4-12345ab9012" \
--configuration httpsNotificationConfiguration={"targetRoleArn"="arn:aws:iam::XXX:role/service-role/RoleName", "endpoint"="https://account-management.$3.$2.securitylake.aws.dev/v1/datalake"}
```

若要取得 `subscriberID`，請使用 Security Lake API 的 [ListSubscribers](https://docs.aws.amazon.com//security-lake/latest/APIReference/API_ListSubscribers.html) 操作。如果您使用的是 AWS Command Line Interface (AWS CLI)，請執行 [list-subscriber](https://docs.aws.amazon.com/cli/latest/reference/securitylake/list-subscribers.html) 命令。

```
$ aws securitylake list-subscribers
```

------

若要後續變更訂閱者的通知方法 (Amazon SQS 佇列或 HTTPS 端點），請使用 [UpdateSubscriberNotification](https://docs.aws.amazon.com/security-lake/latest/APIReference/API_UpdateSubscriberNotification.html) 操作，或者，如果您使用的是 AWS CLI，請執行 [update-subscriber-notification](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/securitylake/update-subscriber-notification.html) 命令。您也可以使用 Security Lake 主控台變更通知方法：在訂閱者頁面上選取**訂閱者**，然後選擇**編輯**。

## 物件通知訊息範例
<a name="sample-notification"></a>

下列範例顯示 `CreateSubscriberNotification`操作的 JSON 結構格式事件通知。

```
{
  "source": "aws.s3",
  "time": "2021-11-12T00:00:00Z",
  "account": "123456789012",
  "region": "ca-central-1",
  "resources": [
    "arn:aws:s3:::amzn-s3-demo-bucket"
  ],
  "detail": {
    "bucket": {
      "name": "amzn-s3-demo-bucket"
    },
    "object": {
      "key": "example-key",
      "size": 5,
      "etag": "b57f9512698f4b09e608f4f2a65852e5"
    },
    "request-id": "N4N7GDK58NMKJ12R",
    "requester": "securitylake.amazonaws.com"
  }
}
```