

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

# 使用 OpenSearch 擷取管道搭配 Amazon Security Lake 做為來源
<a name="configure-client-source-security-lake"></a>

您可以在 OpenSearch 擷取管道中使用 Amazon S3 來源外掛程式，從 Amazon Security Lake 擷取資料。Security Lake 會自動將來自 AWS 環境、內部部署系統和 SaaS 供應商的安全資料集中到專用資料湖中。

Amazon Security Lake 在管道中具有下列中繼資料屬性：
+ `bucket_name`：Security Lake 為存放安全資料而建立的 Amazon S3 儲存貯體名稱。
+ `path_prefix`：Security Lake IAM 角色政策中定義的自訂來源名稱。
+ `region`： AWS 區域 Security Lake S3 儲存貯體所在的 。
+ `accountID`：啟用 Security Lake 的 AWS 帳戶 ID。
+ `sts_role_arn`：旨在與 Security Lake 搭配使用之 IAM 角色的 ARN。

## 先決條件
<a name="sl-prereqs"></a>

建立 OpenSearch Ingestion 管道之前，請執行下列步驟：
+ [啟用 Security Lake](https://docs.aws.amazon.com/security-lake/latest/userguide/getting-started.html#enable-service)。
+ 在 Security Lake 中[建立訂閱者](https://docs.aws.amazon.com/security-lake/latest/userguide/subscriber-data-access.html#create-subscriber-data-access)。
  + 選擇您要擷取至管道的來源。
  + 針對**訂閱者登入**資料，新增您要建立管道之 AWS 帳戶 的 ID。針對外部 ID，指定 `OpenSearchIngestion-{accountid}`。
  + 針對**資料存取方法**，選擇 **S3**。
  + 如需**通知詳細資訊**，請選擇 **SQS 佇列**。

當您建立訂閱者時，Security Lake 會自動建立兩個內嵌許可政策，一個用於 S3，另一個用於 SQS。這些政策採用下列格式： `AmazonSecurityLake-amzn-s3-demo-bucket-S3`和 `AmazonSecurityLake-AWS Demo-SQS`。若要允許管道存取訂閱者來源，您必須將必要的許可與管道角色建立關聯。

## 設定管道角色
<a name="sl-pipeline-role"></a>

在 IAM 中建立新的許可政策，只結合 Security Lake 自動建立的兩個政策所需的許可。下列範例政策顯示 OpenSearch 擷取管道從多個 Security Lake 來源讀取資料所需的最低權限：

------
#### [ JSON ]

****  

```
{
   "Version":"2012-10-17",		 	 	 
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:GetObject"
         ],
         "Resource":[
            "arn:aws:s3:::aws-security-data-lake-us-east-1-abcde/aws/LAMBDA_EXECUTION/1.0/*",
            "arn:aws:s3:::aws-security-data-lake-us-east-1-abcde/aws/S3_DATA/1.0/*",
            "arn:aws:s3:::aws-security-data-lake-us-east-1-abcde/aws/VPC_FLOW/1.0/*",
            "arn:aws:s3:::aws-security-data-lake-us-east-1-abcde/aws/ROUTE53/1.0/*",
            "arn:aws:s3:::aws-security-data-lake-us-east-1-abcde/aws/SH_FINDINGS/1.0/*"
         ]
      },
      {
         "Effect":"Allow",
         "Action":[
            "sqs:ReceiveMessage",
            "sqs:DeleteMessage"
         ],
         "Resource":[
            "arn:aws:sqs:us-east-1:111122223333:AmazonSecurityLake-abcde-Main-Queue"
         ]
      }
   ]
}
```

------

**重要**  
Security Lake 不會為您管理管道角色政策。如果您從 Security Lake 訂閱新增或移除來源，則必須手動更新政策。Security Lake 會為每個日誌來源建立分割區，因此您需要在管道角色中手動新增或移除許可。

您必須將這些許可連接到您在 S3 來源外掛程式組態中的 `sts_role_arn`選項中指定的 IAM 角色，位於 下`sqs`。

```
version: "2"
source:
  s3:
    ...
    sqs:
      queue_url: "https://sqs.us-east-1amazonaws.com/account-id/AmazonSecurityLake-amzn-s3-demo-bucket-Main-Queue"
    aws:
      ...
processor:
  ...
sink:
  - opensearch:
      ...
```

## 建立管道
<a name="sl-pipeline"></a>

將許可新增至管道角色之後，請使用預先設定的 Security Lake 藍圖來建立管道。如需詳細資訊，請參閱[使用藍圖](pipeline-blueprint.md)。

您必須在`s3`來源組態中指定 `queue_url`選項，這是要讀取的 Amazon SQS 佇列 URL。若要格式化 URL，請在訂閱者組態中尋找**訂閱端點**，並`arn:aws:`變更為 `https://`。例如 `https://sqs.us-east-1amazonaws.com/account-id/AmazonSecurityLake-AWS Demo-Main-Queue`。

`sts_role_arn` 您在 S3 來源組態中指定的 必須是管道角色的 ARN。