

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Amazon Detective 与亚马逊安全湖集成
<a name="securitylake-integration"></a>

Amazon Security Lake 是一项完全托管的安全数据湖服务。您可以使用 Security Lake 自动将来自 AWS 环境、SaaS 提供商、本地资源、云源和第三方来源的安全数据集中到存储在您账户中的专用数据湖中。 AWS Security Lake 可以帮助您分析安全数据，让您更全面地了解整个组织的安全状况。借助 Security Lake，您还可以改善对工作负载、应用程序和数据的保护。

Amazon Detective 与 Amazon Security Lake 集成，这意味着您可以查询和检索 Security Lake 存储的原始日志数据。

使用此集成，您可以从 Security Lake 原生支持的以下来源收集日志和事件。Detective 最多支持源版本 2（OCSF 1.1.0）。
+ AWS CloudTrail 管理事件版本 1.0 及更高版本
+ 亚马逊 Virtual Private Cloud（亚马逊 VPC）流日志 1.0 及更高版本
+ 亚马逊 Elastic Kubernetes Service（亚马逊 EKS）审核日志版本 2.0。— 要使用 Amazon EKS 审计日志作为来源，您必须添加`ram:ListResources`到 IAM 权限中。有关更多详细信息，请参阅[向您的账户添加所需的 IAM 权限](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#iam-permissions)。

 有关 Security Lake 如何自动将来自原生支持的 AWS 服务的日志和事件转换为 OCSF 架构的详细信息，请参阅 A [mazon Secur](https://docs.aws.amazon.com//security-lake/latest/userguide/open-cybersecurity-schema-framework.html) ity Lake 用户指南。

将 Detective 与 Security Lake 集成后，Detective 开始从安全湖中提取与 AWS CloudTrail 管理事件和 Amazon VPC 流日志相关的原始日志。有关更多详细信息，请参阅[查询原始日志](https://docs.aws.amazon.com//detective/latest/userguide/profile-panel-drilldown-overall-api-volume.html#drilldown-api-volume-time-range)。

# 启用 Detective 与安全湖的集成
<a name="integrating-securitylake-tutorial"></a>

要将 Detective 与 Security Lake 集成，你必须完成以下步骤。

1. [开始之前](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#Prerequisites)

   使用 Organizations 管理账户来为您的组织指定一个委托的 Security Lake 管理员。确保安全湖已启用，并确认安全湖正在从 AWS CloudTrail 管理事件和亚马逊虚拟私有云 (Amazon VPC) 流日志中收集日志和事件。

   为了与安全参考架构保持一致，Detective 建议使用日志存档帐户，并推迟使用安全工具帐户进行 Security Lake 部署。

1. [创建安全湖订阅者](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#securitylake-subscriber)

   要使用来自 Amazon Security Lake 的日志和事件，您必须为 Security Lake 订阅用户。按照以下步骤向 Detective 账户管理员授予查询权限。

1. 为您的 IAM 身份添加所需的 AWS Identity and Access Management (IAM) 权限。
   + 添加以下权限以创建 Detective 与 Security Lake 集成：
     + 将这些 AWS 身份和访问管理 (IAM) 权限附加到您的 IAM 身份。有关详细信息，请参阅[向您的账户添加所需的 IAM 权限](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#iam-permissions)部分。
     + 将此 IAM 策略添加到您计划用于传递 CloudFormation 服务角色的 IAM 委托人中。有关更多详细信息，请参阅向您的 [IAM 委托人添加权限](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#cloud-formation-template)部分。
   + 如果您已经将 Detective 与 Security Lake 集成，则要使用集成，请将这些 (IAM) 权限附加到您的 IAM 身份。有关详细信息，请参阅[向您的账户添加所需的 IAM 权限](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#iam-permissions)部分。

1. [接受资源共享 ARN 邀请并启用集成](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#resource-share-arn)

使用 AWS CloudFormation 模板设置创建和管理 Security Lake 订阅者的查询访问权限所需的参数。有关创建堆栈的详细步骤，请参阅[使用 AWS CloudFormation 模板创建堆栈](https://docs.aws.amazon.com//detective/latest/userguide/securitylake-integration.html#cloud-formation-template)。创建完堆栈后，启用集成。

要演示如何使用 Detective 控制台将 Amazon Detective 与 Amazon Security Lake 集成，请观看以下视频：

[![AWS Videos](http://img.youtube.com/vi/https://www.youtube.com/embed/73ZurSZCZwA/0.jpg)](http://www.youtube.com/watch?v=https://www.youtube.com/embed/73ZurSZCZwA)


# 在开始将 Detective 与 Security Lake
<a name="Prerequisites"></a>

本主题介绍初步步骤，例如为您的组织委派 Security Lake 管理员、为您的 Detective 管理员帐户启用 Security Lake 以及验证 Security Lake 是否正在收集日志和事件。

Security Lake 与 AWS Organizations 集成，可管理组织中多个账户的日志收集。要为组织使用 Security Lake，您的 AWS Organizations 管理账户必须先为您的组织指定一名委派的 Security Lake 管理员。然后，委托的 Security Lake 管理员必须启用 Security Lake，并为组织中的成员账户启用日志和事件收集。

在将 Security Lake 与 Detective 集成之前，请确保已为 Detective 管理员帐户启用 Security Lake。您必须首先使用安全湖控制台启用安全湖来配置数据湖设置并设置日志收集。有关如何启用 Security Lake 的详细步骤，请参阅《Amazon Security Lake 用户指南》中的[入门](https://docs.aws.amazon.com//security-lake/latest/userguide/getting-started.html)。

此外，请验证 Security Lake 是否正在从 AWS CloudTrail 管理事件和亚马逊虚拟私有云（Amazon VPC）流日志中收集日志和事件。有关安全湖中日志收集的更多详细信息，请参阅 Amazon Security Lake 用户指南中的[从 AWS 服务收集数据](https://docs.aws.amazon.com//security-lake/latest/userguide/internal-sources.html#cloudtrail-event-logs)。

# 第 1 步：在 Detective 中创建安全湖订阅者
<a name="securitylake-subscriber"></a>

本主题介绍如何使用 Detective 控制台创建 Security Lake 订阅者。

要使用来自 Amazon Security Lake 的日志和事件，您必须为 Security Lake 订阅用户。订阅用户可以查询和访问 Security Lake 收集的数据。具有查询权限的订阅者可以使用诸如亚马逊 Athena 之类的服务直接在亚马逊简单存储服务 (Amazon S3) 存储桶中查询 AWS Lake Formation 表。要成为订阅用户，Security Lake 管理员必须为您提供允许您查询数据湖的订阅用户访问权限。有关管理员如何执行此操作的信息，请参阅《Amazon Security Lake 用户指南》中的[创建具有查询权限的订阅用户](https://docs.aws.amazon.com//security-lake/latest/userguide/subscriber-query-access.html#create-query-subscriber-procedures)。

按照以下步骤创建 Security Lake 订阅者，以便向 Detective 管理员帐户授予查询权限。

**在 Security Lake 中创建 Detective 订阅用户**

1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在导航窗格中，选择**集成**。

1. 在 Security Lake 订阅用户窗格中，记下**账户 ID** 和**外部 ID** 值。

   让 Security Lake 管理员 IDs 使用它们来：
   + 在 Security Lake 中为您创建 Detective 订阅用户。
   + 将订阅用户配置为具有查询权限。
   + 要确保创建具有 Lake Formation 权限的 Security Lake 查询订阅用户，请在 Security Lake 控制台中选择 **Lake Formation** 作为**数据访问方式**。

   当 Security Lake 管理员为您创建订阅用户时，Security Lake 会为您生成一个 Amazon 资源共享 ARN。要求管理员将此 ARN 发送给您。

1. 在 **Security Lake 订阅用户**窗格中输入 Security Lake 管理员提供的**资源共享 ARN**。

1. 收到 Security Lake 管理员的资源共享 ARN 后，在 **Security Lake 订阅用户**窗格的**资源共享 ARN** 框中输入 ARN。

# 第 2 步：在 Detective 中向你的账户添加所需的 IAM 权限
<a name="iam-permissions"></a>

本主题说明了您必须添加到您的 IAM 身份的 AWS Identity and Access Management (IAM) 权限策略的详细信息。

要启用 Detective 与 Security Lake 的集成，您必须将以下 AWS Identity and Access Management (IAM) 权限策略附加到您的 IAM 身份。

将下面的内联策略附加到角色。如果您想使用自己的 Amazon S3 存储桶来存储 Athena 查询结果，请将 `athena-results-bucket` 替换为您的 Amazon S3 存储桶名称。如果您希望 Detective 自动生成 Amazon S3 存储桶来存储 Athena 查询结果，请从 IAM 策略中删除全部 `S3ObjectPermissions`。

如果您没有将此策略附加到您的 IAM 身份所需的权限，请联系您的 AWS 管理员。如果您拥有所需权限但出现问题，请参阅 IAM 用户指南中的[排除访问被拒绝错误消息](https://docs.aws.amazon.com//IAM/latest/UserGuide/troubleshoot_access-denied.html)。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListAllMyBuckets"
            ],
            "Resource": "*"
        },
        {
            "Sid": "S3ObjectPermissions",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket",
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "glue:GetDatabases",
                "glue:GetPartitions",
                "glue:GetTable",
                "glue:GetTables"
            ],
            "Resource": [
                "arn:aws:glue:*:123456789012:database/amazon_security_lake*",
                "arn:aws:glue:*:123456789012:table/amazon_security_lake*/amazon_security_lake*",
                "arn:aws:glue:*:123456789012:catalog"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "athena:BatchGetQueryExecution",
                "athena:GetQueryExecution",
                "athena:GetQueryResults",
                "athena:GetQueryRuntimeStatistics",
                "athena:GetWorkGroup",
                "athena:ListQueryExecutions",
                "athena:StartQueryExecution",
                "athena:StopQueryExecution",
                "lakeformation:GetDataAccess",
                "ram:ListResources"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ssm:GetParametersByPath"
            ],
            "Resource": [
                "arn:aws:ssm:*:123456789012:parameter/Detective/SLI"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "cloudformation:GetTemplateSummary",
                "iam:ListRoles"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "organizations:ListDelegatedAdministrators"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "organizations:ServicePrincipal": [
                        "securitylake.amazonaws.com"
                    ]
                }
            }
        }
    ]
}
```

------

# 步骤 3：接受资源共享 ARN 邀请
<a name="resource-share-arn"></a>

本主题介绍使用 AWS CloudFormation 模板接受资源共享 ARN 邀请的步骤，这是启用 Detective 与 Security Lake 集成之前的必需步骤。

要从 Security Lake 访问原始数据日志，您必须接受 Security Lake 管理员创建的 Security Lake 账户发出的资源共享邀请。您还需要设置跨账户表共享的 AWS Lake Formation 权限。此外，您还必须创建可接收原始查询日志的 Amazon Simple Storage Service（Amazon S3）存储桶。

在下一步中，您将使用 AWS CloudFormation 模板为以下内容创建堆栈：接受资源共享 ARN 邀请、创建所需 AWS Glue 爬网程序 资源和授予 AWS Lake Formation 管理员权限。

**接受资源共享 ARN 邀请并启用集成**

1. 使用 CloudFormation 模板创建新 CloudFormation 堆栈。有关更多详细信息，请参阅[使用 CloudFormation 模板创建堆栈](#cloud-formation-template)。

1. 创建完堆栈后，选择 “**启用集成**” 以启用 Detective 与 Security Lake 的集成。

## 使用 CloudFormation 模板创建堆栈
<a name="cloud-formation-template"></a>

Detective 提供了一个 CloudFormation 模板，您可以使用该模板来设置创建和管理 Security Lake 订阅者的查询访问权限所需的参数。

**步骤 1：创建 AWS CloudFormation 服务角色**

必须创建 CloudFormation 服务角色才能使用 CloudFormation 模板创建堆栈。如果您没有创建服务角色所需的权限，请联系 Detective 管理员账户的管理员。有关 AWS CloudFormation 服务角色的更多信息，请参阅 [AWS CloudFormation 服务角色](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-servicerole.html)。

1. 登录 AWS 管理控制台 并打开 IAM 控制台，网址为[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)。

1. 在 IAM 控制台的导航窗格中，选择**角色**，然后选择**创建角色**。

1. 对于**选择可信实体**，选择 **AWS 服务**。

1. 选择 **CloudFormation**。然后选择**下一步**。

1. 输入角色的名称。例如 `CFN-DetectiveSecurityLakeIntegration`。

1. 将下面的内联策略附加到角色。`<Account ID>`替换为您的 AWS 账户 ID。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CloudFormationPermission",
            "Effect": "Allow",
            "Action": [
                "cloudformation:CreateChangeSet"
            ],
            "Resource": [
                "arn:aws:cloudformation:*:aws:transform/*"
            ]
        },
        {
            "Sid": "IamPermissions",
            "Effect": "Allow",
            "Action": [
                "iam:CreateRole",
                "iam:DeleteRole",
                "iam:AttachRolePolicy",
                "iam:DetachRolePolicy",
                "iam:UpdateAssumeRolePolicy",
                "iam:PutRolePolicy",
                "iam:DeleteRolePolicy",
                "iam:CreatePolicy",
                "iam:DeletePolicy",
                "iam:PassRole",
                "iam:GetRole",
                "iam:GetRolePolicy"
            ],
            "Resource": [
                 "arn:aws:iam::111122223333:role/*-ResourceShareAcceptorLamb-*",
                 "arn:aws:iam::111122223333:role/*-SsmParametersLambdaRole-*",
                 "arn:aws:iam::111122223333:role/*-GlueDatabaseLambdaRole-*",
                 "arn:aws:iam::111122223333:role/*-GlueTablesLambdaRole-*",
                 "arn:aws:iam::111122223333:policy/*"
            ]
        },
        {
            "Sid": "S3Permissions",
            "Effect": "Allow",
            "Action": [
                "s3:CreateBucket",
                "s3:DeleteBucket*",
                "s3:PutBucket*",
                "s3:GetBucket*",
                "s3:GetObject",
                "s3:PutEncryptionConfiguration",
                "s3:GetEncryptionConfiguration"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Sid": "LambdaPermissions",
            "Effect": "Allow",
            "Action": [
                "lambda:CreateFunction",
                "lambda:DeleteFunction",
                "lambda:GetFunction",
                "lambda:TagResource",
                "lambda:InvokeFunction"
            ],
            "Resource": [
                "arn:aws:lambda:*:111122223333:function:*"
            ]
        },
        {
            "Sid": "CloudwatchPermissions",
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:DeleteLogGroup",
                "logs:DescribeLogGroups"
            ],
            "Resource": "arn:aws:logs:*:111122223333:log-group:*"
        },
        {
            "Sid": "KmsPermission",
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt"
            ],
            "Resource": "arn:aws:kms:*:111122223333:key/*"
        }
    ]
}
```

------

**第 2 步：为您的 IAM 委托人添加权限**。

您需要以下权限才能使用您在上一步中创建的 CloudFormation 服务角色创建堆栈。将以下 IAM 策略添加到您计划用于传递 CloudFormation 服务角色的 IAM 委托人。您将假设这个 IAM 主体来创建堆栈。如果您没有添加 IAM 策略所需的权限，请联系 Detective 管理员账户的管理员。

**注意**  
在以下策略中，本策略中使用的 `CFN-DetectiveSecurityLakeIntegration` 是指您在前面的 `Creating an AWS CloudFormation` 服务角色步骤中创建的角色。如果不一致，请将其更改为您在之前步骤中输入的角色名称。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "PassRole",
            "Effect": "Allow",
            "Action": [
                "iam:GetRole",
                "iam:PassRole"
            ],
            "Resource": "arn:aws:iam::111122223333:role/CFN-DetectiveSecurityLakeIntegration"
        },
        {
            "Sid": "RestrictCloudFormationAccess",
            "Effect": "Allow",
            "Action": [
                "cloudformation:CreateStack",
                "cloudformation:DeleteStack",
                "cloudformation:UpdateStack"
            ],
            "Resource": "arn:aws:cloudformation:*:111122223333:stack/*",
            "Condition": {
                "StringEquals": {
                    "cloudformation:RoleArn": [
                        "arn:aws:iam::111122223333:role/CFN-DetectiveSecurityLakeIntegration"
                    ]
                }
            }
        },
        {
            "Sid": "CloudformationDescribeStack",
            "Effect": "Allow",
            "Action": [
                "cloudformation:DescribeStacks",
                "cloudformation:DescribeStackEvents",
                "cloudformation:GetStackPolicy"
            ],
            "Resource": "arn:aws:cloudformation:*:111122223333:stack/*"
        },
        {
            "Sid": "CloudformationListStacks",
            "Effect": "Allow",
            "Action": [
                "cloudformation:ListStacks"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CloudWatchPermissions",
            "Effect": "Allow",
            "Action": [
                "logs:GetLogEvents"
            ],
            "Resource": "arn:aws:logs:*:111122223333:log-group:*"
        }
    ]
}
```

------

**步骤 3：在 CloudFormation 控制台中指定自定义值**

1. 从 Detective 进入 AWS CloudFormation 控制台。

1. （可选）输入**堆栈名称**。堆栈名称是自动填充的。您可以将堆栈名称更改为与现有堆栈名称不冲突的名称。

1. 输入以下**参数**。
   + **AthenaResultsBucket**— 如果您不输入值，则此模板会生成一个 Amazon S3 存储桶。如果您想使用自己的存储桶，请输入要存储 Athena 查询结果的存储桶名称。如果您使用自己的存储桶，请确保存储桶与资源共享 ARN 位于同一区域。如果您使用自己的存储桶，请确保您选择的 `LakeFormationPrincipals` 具有向存储桶写入对象和从存储桶读取对象的权限。有关存储桶权限的更多详细信息，请参阅《Amazon Athena 用户指南》中的[查询结果和最近查询](https://docs.aws.amazon.com/athena/latest/ug/querying.html)。
   + **DTRegion**— 此字段已预先填写。请不要更改此字段中的值。
   + **LakeFormationPrincipals**— 输入您想要授予使用安全湖集成的权限的 IAM 委托人（例如，IAM 角色 ARN）的 ARN，以逗号分隔。这些可能是你的安全分析师和使用 Detective 的安全工程师。

     您只能使用之前在步骤 [`Step 2: Add the required IAM permissions to your account]` 中附加了 IAM 权限的 IAM 主体。
   + **ResourceShareARN**-此字段已预先填写。请不要更改此字段中的值。

1. **权限**

   **IAM 角色**：选择您在 `Creating an AWS CloudFormation Service Role` 步骤中创建的角色。或者，可以将其留空（如果您的当前 IAM 角色具有 `Creating an AWS CloudFormation Service Role` 步骤中的所有必需权限）。

1. 查看并选中所有**我确认**复选框，然后单击**创建堆栈**按钮。有关更多详细信息，请查看将要创建的以下 IAM 资源。

```
* ResourceShareAcceptorCustomResourceFunction
    - ResourceShareAcceptorLambdaRole
    - ResourceShareAcceptorLogsAccessPolicy
* SsmParametersCustomResourceFunction
    - SsmParametersLambdaRole
    - SsmParametersLogsAccessPolicy
* GlueDatabaseCustomResourceFunction
    - GlueDatabaseLambdaRole
    - GlueDatabaseLogsAccessPolicy
* GlueTablesCustomResourceFunction
    - GlueTablesLambdaRole
    - GlueTablesLogsAccessPolicy
```

**第 4 步：将 Amazon S3 存储桶策略添加到 IAM 委托人 `LakeFormationPrincipals`**

（可选）如果您让此模板为您生成 `AthenaResultsBucket`，则必须将以下策略附加到 `LakeFormationPrincipals` 中的 IAM 主体。

```
{
  "Sid": "S3ObjectPermissions",
  "Effect": "Allow",
  "Action": [
    "s3:GetObject",
    "s3:PutObject"
  ],
  "Resource": [
    "arn:aws:s3:::<athena-results-bucket>",
    "arn:aws:s3:::<athena-results-bucket>/*"
  ]
}
```

`athena-results-bucket`替换为`AthenaResultsBucket`名称。 `AthenaResultsBucket`可以在 AWS CloudFormation 控制台上找到：

1. 在 [https://console.aws.amazon.com/cloudformat](https://console.aws.amazon.com/cloudformation/) ion 上打开 CloudFormation 控制台。

1. 单击您的堆栈。

1. 单击**资源**选项卡。

1. 搜索逻辑 ID `AthenaResultsBucket` 并复制其物理 ID。

# 更改 Detective 集成配置
<a name="edit-integration"></a>

如果要更改用于将 Detective 与 Security Lake 集成的任何参数，可以对其进行编辑，然后再次启用集成。您可以编辑 CloudFormation 模板以在以下情况下重新启用此集成：
+ 要更新 Security Lake 订阅，您可以创建新的订阅用户，也可以让 Security Lake 管理员更新现有订阅的数据来源。
+ 指定用于存储原始查询日志的其他 Amazon S3 存储桶。
+ 指定其他 Lake Formation 主体。

重新启用 Detective 与 Security Lake 的集成时，您可以编辑**资源共享 ARN**，并查看 **IAM 权限**。要编辑 IAM 权限，您可以从 Detective 转到 IAM 控制台。您也可以编辑先前在 CloudFormation 模板中输入的值。您必须删除现有 CloudFormation 堆栈并重新创建它才能重新启用集成。

**重新启用 Detective 与 Security Lake 的集成**

1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在导航窗格中，选择**集成**。

1. 您可以使用以下任一步骤编辑集成：
   + 在 **Security Lake** 窗格中，选择**编辑**。
   + 在 **Security Lake** 窗格中，选择**视图**。在视图页面中，选择**编辑**。

1. 输入新的**资源共享 ARN**，以访问区域中的数据来源。

1. 查看当前 IAM 权限，并转到 IAM 控制台（如果您想编辑 IAM 权限）。

1. 编辑 CloudFormation 模板中的值。

   1. 在创建新堆栈之前，请先删除现有堆栈。如果您不删除现有堆栈并尝试在同一区域创建新堆栈，则您的请求将失败。有关更多详细信息，请参阅[删除堆 CloudFormation 栈](disable-integration.md#delete-stack)。

   1. 创建新 CloudFormation 堆栈。有关更多详细信息，请参阅[使用 CloudFormation 模板创建堆栈](resource-share-arn.md#cloud-formation-template)。

1. 选择**启用集成**。

# 支持将 Detective 与安全湖集成的 AWS 区域
<a name="supported-regions"></a>

你可以在以下 AWS 区域将 Detective 与 Security Lake 集成。


****  

| 区域名称 | 区域 | 端点 | 协议 | 
| --- | --- | --- | --- | 
| 美国东部（俄亥俄州） | us-east-2 |  securitylake.us-east-2.amazonaws.com  | HTTPS | 
| 美国东部（弗吉尼亚州北部） | us-east-1 |  securitylake.us-east-1.amazonaws.com  | HTTPS | 
| 美国西部（北加利福尼亚） | us-west-1 |  securitylake.us-west-1.amazonaws.com  | HTTPS | 
| 美国西部（俄勒冈州） | us-west-2 |  securitylake.us-west-2.amazonaws.com  | HTTPS | 
| 亚太地区（孟买） | ap-south-1 |  securitylake.ap-south-1.amazonaws.com  | HTTPS | 
| 亚太地区（首尔） | ap-northeast-2 |  securitylake.ap-northeast-2.amazonaws.com  | HTTPS | 
| 亚太地区（新加坡） | ap-southeast-1 |  securitylake.ap-southeast-1.amazonaws.com  | HTTPS | 
| 亚太地区（悉尼） | ap-southeast-2 |  securitylake.ap-southeast-2.amazonaws.com  | HTTPS | 
| 亚太地区（东京） | ap-northeast-1 |  securitylake.ap-northeast-1.amazonaws.com  | HTTPS | 
| 加拿大（中部） | ca-central-1 |  securitylake.ca-central-1.amazonaws.com  | HTTPS | 
| 欧洲地区（法兰克福） | eu-central-1 |  securitylake.eu-central-1.amazonaws.com  | HTTPS | 
| 欧洲地区（爱尔兰） | eu-west-1 |  securitylake.eu-west-1.amazonaws.com  | HTTPS | 
| 欧洲地区（伦敦） | eu-west-2 |  securitylake.eu-west-2.amazonaws.com  | HTTPS | 
| 欧洲地区（巴黎） | eu-west-3 |  securitylake.eu-west-3.amazonaws.com  | HTTPS | 
| 欧洲地区（斯德哥尔摩） | eu-north-1 |  securitylake.eu-north-1.amazonaws.com  | HTTPS | 
| 南美洲（圣保罗） | sa-east-1 |  securitylake.sa-east-1.amazonaws.com  | HTTPS | 

# 在 Detective 中查询原始日志
<a name="query-raw-logs-detective"></a>

将 Detective 与 Security Lake 集成后，Detective 开始从安全湖提取与 AWS CloudTrail 管理事件和亚马逊虚拟私有云（亚马逊 VPC）流日志相关的原始日志。

**注意**  
在 Detective 中查询原始日志不会产生额外费用。包括亚马逊 Athena 在内的其他 AWS 服务的使用费仍按公布费率收取。

AWS CloudTrail 管理事件适用于以下配置文件：
+ AWS 账户
+ AWS 用户
+ AWS 角色
+ AWS 角色会话
+ Amazon EC2 实例
+ 亚马逊 S3 存储桶
+ IP 地址
+ Kubernetes 集群
+ Kubernetes 容器组（pod）
+ Kubernetes 主题
+ IAM 角色
+ IAM 角色会话
+ IAM 用户

Amazon VPC FLow 日志适用于以下配置文件：
+ Amazon EC2 实例
+ Kubernetes 容器组（pod）

要演示如何使用 Detective 控制台将 Amazon Detective 与 Amazon Security Lake 配合使用，请观看以下视频：

[![AWS Videos](http://img.youtube.com/vi/https://www.youtube.com/embed/A_EWd2lvVW0/0.jpg)](http://www.youtube.com/watch?v=https://www.youtube.com/embed/A_EWd2lvVW0)


**查询 AWS 账户的原始日志**

1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在导航窗格中，选择**搜索**，然后搜索 `AWS account`。

1. 在 **API 调用总量**部分中，选择**显示范围时间的详细信息**。

1. 在此处，您可以开始**查询原始日志**。

![\[在原始日志预览表中，您可以查看通过查询 Security Lake 数据检索到的日志和事件。有关原始事件日志的更多详细信息，您可以查看 Amazon Athena 中显示的数据。\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/images/query-raw-logs-awsaccount.png)


在**原始日志预览**表中，您可以查看通过查询 Security Lake 数据检索到的日志和事件。有关原始事件日志的更多详细信息，您可以查看 Amazon Athena 中显示的数据。

![\[在原始日志预览表中，您可以查看通过查询 Security Lake 数据检索到的日志和事件。有关原始事件日志的更多详细信息，您可以查看 Amazon Athena 中显示的数据。\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/images/query-raw-log-table.png)


在查询原始日志表中，您可以**取消查询请求**，**在 Amazon Athena 中查看结果**，并**下载结果** [下载为逗号分隔值（.csv）文件]。

如果您在 Detective 中看到日志，但查询未返回任何结果，则可能是由于以下原因而引起的。
+ 原始日志可能会先在 Detective 中可用，然后才显示在 Security Lake 日志表中。请稍后重试。
+ Security Lake 中可能缺少日志。如果您等待了很长时间，则表示 Security Lake 中缺少日志。要解决该问题，请联系您的 Security Lake 管理员。

**Topics**
+ [查询 AWS 角色的原始日志](#query-log-geo-location)
+ [查询 Amazon EKS 集群的原始日志](#query-log-eks-cluster)
+ [查询 Amazon EC2 实例的原始日志](#query-log-vpc)

## 查询 AWS 角色的原始日志
<a name="query-log-geo-location"></a>

如果您想了解新地理位置中 AWS 角色的活动，可以在 Detective 控制台中进行操作。



**查询 AWS 角色的原始日志**

1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在 Detective **Su** mm **ary 页面的 “新观察到的地理位置**” 部分，记下该 AWS 角色。

1. 在导航窗格中，选择**搜索**，然后搜索 `AWS role`。

1.  对于该 AWS 角色，展开资源以显示该资源从该 IP 地址发出的特定 API 调用。

1. 选择要调查的 API 调用旁边的放大镜图标，以打开**原始日志预览**表。  
![\[在原始日志预览表中，您可以查看通过查询 Security Lake 数据检索到的日志和事件。有关原始事件日志的更多详细信息，您可以查看 Amazon Athena 中显示的数据。\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/images/query-raw-logs-awsrole.png)

## 查询 Amazon EKS 集群的原始日志
<a name="query-log-eks-cluster"></a>

1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 从 Detective **摘要**页面**创建的 pod 最多的容器集群**部分，导航到 Amazon EKS 集群。

1. 在 **Amazon EKS 集群详情**页面中，选择 **Kubernetes API** 活动选项卡。

1. 在涉及**此 Amazon EKS 集群的 Kubernetes API 总体活动**部分中，选择范围**时间的显示详情。**

1. 在此处，您可以开始**查询原始日志**。

## 查询 Amazon EC2 实例的原始日志
<a name="query-log-vpc"></a>



1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在导航窗格中，选择**搜索**，然后搜索 `Amazon EC2 instance`。

1. 在 **VPC 的总流量**部分，选择要调查的 API 调用旁边的放大镜图标，以打开**原始日志预览**表。

1. 在此处，您可以开始**查询原始日志**。  
![\[在原始日志预览表中，您可以查看通过查询 Security Lake 数据检索到的日志和事件。有关原始事件日志的更多详细信息，您可以查看 Amazon Athena 中显示的数据。\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/images/query-raw-log-vpc.png)

在**原始日志预览**表中，您可以查看通过查询 Security Lake 数据检索到的日志和事件。有关原始事件日志的更多详细信息，您可以查看 Amazon Athena 中显示的数据。

在查询原始日志表中，您可以**取消查询请求**，**在 Amazon Athena 中查看结果**，并**下载结果** [下载为逗号分隔值（.csv）文件]。

# 禁用 Detective 与安全湖集成
<a name="disable-integration"></a>

如果您禁用 Detective 与 Security Lake 的集成，则无法再从 Security Lake 中查询日志和事件数据。

**禁用 Detective 与 Security Lake 的集成**

1. 打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在导航窗格中，选择**集成**。

1. 删除现有堆栈。有关更多详细信息，请参阅[删除堆 CloudFormation 栈](#delete-stack)。

1. 在**禁用 Security Lake 集成**窗格中，选择**禁用**。

## 删除堆 CloudFormation 栈
<a name="delete-stack"></a>

如果您不删除现有堆栈，则在同一区域创建新堆栈将失败。您可以使用 CloudFormation 控制台或使用 AWS CLI 删除 CloudFormation 堆栈。

**删除 CloudFormation 堆栈（控制台）**

1. 在 [https://console.aws.amazon.com/cloudformat](https://console.aws.amazon.com/cloudformation/) ion 上打开 AWS CloudFormation 控制台。

1. 在 CloudFormation 控制台的**堆栈**页面上，选择要删除的堆栈。该堆栈当前必须处于运行状态。

1. 在堆栈详细信息窗格中，选择**删除**。

1. 在系统提示时，选择**删除堆栈**。
**注意**  
堆栈删除开始后，就无法停止堆栈删除操作。堆栈进入 `DELETE_IN_PROGRESS` 状态。

堆栈删除过程完成之后，堆栈将处于 `DELETE_COMPLETE` 状态。

**排查堆栈删除错误**

如果您在单击`Delete`按钮`Failed to delete stack`后看到该消息出现权限错误，则表示您的 IAM 角色无 CloudFormation 权删除堆栈。请联系您的账户管理员以删除堆栈。

**删除 CloudFormation 堆栈 (AWS CLI)**

在 AWS CLI 界面中输入以下命令：

```
aws cloudformation delete-stack --stack-name your-stack-name --role-arn
      arn:aws:iam::<ACCOUNT ID>:role/CFN-DetectiveSecurityLakeIntegration
```

`CFN-DetectiveSecurityLakeIntegration` 是您在 `Creating an AWS CloudFormation Service Role` 步骤中创建的服务角色。