

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

# 在 Detective 中管理账户
<a name="accounts"></a>

当一个账户启用 Detective 时，它会成为行为图的管理员账户，并为行为图选择成员账户。管理员账户可以邀请账号加入行为图。当账户接受邀请时，Detective 会将该账户启用为成员账户。通过邀请添加的成员账户可以从行为图中删除自己。

当一个账户被启用为成员账户时，Detective 就会开始摄取并提取该成员账户的数据到行为图中。

每个行为图表都包含来自一个或多个账户的数据。一张行为图最多可以有 1200 个成员账户。

如果您已与集成 AWS Organizations，则组织管理帐户会为该组织指定 Detective 管理员帐户。然后，该 Detective 管理员账户成为组织行为图的管理员账户。Detective 管理员账户在组织行为图中选择要作为成员账户启用的组织账户。组织账户不能从组织行为图中删除自己。

Detective 会根据每个账户为每个行为图提供的数据收取费用。有关在行为图中跟踪每个账户的数据量的信息，请参阅[预测和监控 Amazon Detective 成本](https://docs.aws.amazon.com//detective/latest/userguide/tracking-usage-logging.html)。

**Topics**
+ [

# Detective 中的账号限制和建议
](accounts-restrictions-recommendations.md)
+ [

# 使用 Organizations 管理行为图账户
](accounts-orgs-transition.md)
+ [

# 为组织指定 Detective 管理员
](accounts-designate-admin.md)
+ [

# 账户的可用操作
](accounts-allowed-actions.md)
+ [

# 查看账户列表
](accounts-view-list.md)
+ [

# 以 Detective 成员账户的身份管理组织账户
](accounts-orgs-members.md)
+ [

# 在 Detective 中管理受邀成员账户
](accounts-invited-members.md)
+ [

# 对于成员账号：管理行为图邀请和成员资格
](member-account-graph-management.md)
+ [

# 账户操作对行为图的影响
](accounts-effects.md)
+ [

# 使用 Detective Python 脚本管理账户
](detective-github-scripts.md)

# Detective 中的账号限制和建议
<a name="accounts-restrictions-recommendations"></a>

管理 Amazon Detective 中的账户时，请注意以下限制和建议。

## 成员账户的最大数量
<a name="accounts-maximum-members"></a>

Detective 允许每个行为图中最多有 1200 个成员账户。

如果您使用 AWS Organizations 管理账户，默认情况下，Detective 会在账户**管理页面上显示最多 5000 个成员账户**。如果要查看所有帐户，请选择**加载所有帐户**。返回所有结果可能需要几分钟。

## 账户和区域
<a name="accounts-regions"></a>

如果您使用 AWS Organizations 管理帐户，则组织管理帐户会为组织指定一个 Detective 管理员帐户。该 Detective 管理员账户成为组织行为图的管理员账户。

所有区域的 Detective 管理员账户必须相同。组织管理账户在每个区域分别指定 Detective 管理员账户。Detective 管理员账户还分别管理每个区域的组织行为图和成员账户。

对于通过邀请创建的成员账户，管理员-成员关联仅在发出邀请的区域创建。管理员账户必须在每个区域启用 Detective，并且每个区域都有单独的行为图。然后，管理员账户会邀请每个账户作为该区域的成员账户进行关联。

一个账户可以是同一区域内多个行为图的成员账户。每个区域只能有一个行为图的管理员账户。一个账户可以是不同区域的管理员账户。

## 管理员帐户与 Security Hub CSPM 保持一致以及 GuardDuty
<a name="accounts-alignment"></a>

为确保与 Amazon AWS Security Hub CSPM 和 Amazon 的集成顺利 GuardDuty 进行，我们建议在所有这些服务中使用同一个账户作为管理员账户。

请参阅[建议与 GuardDuty 和对齐 AWS Security Hub CSPM](detective-recommendations.md#recommended-service-alignment)。

## 授予管理员账户所需的权限
<a name="accounts-admin-permissions"></a>

要确保管理员账户拥有管理其行为图所需的权限，请将 [`AmazonDetectiveFullAccess` 托管式策略](security-iam-awsmanpol.md#security-iam-awsmanpol-amazondetectivefullaccess)附加到 IAM 主体。

## 在 Detective 中反映组织的最新动态
<a name="accounts-orgs-update-notification"></a>

组织的更改不会立即反映在 Detective 中。

对于大多数更改，如新增和删除组织账户，Detective 可能需要一个小时才能收到通知。

对 Organizations 中指定的 Detective 管理员账户进行更改所需的传播时间较短。

# 使用 Organizations 管理行为图账户
<a name="accounts-orgs-transition"></a>

可能有一个现有的行为图，其中包含接受手动邀请的成员账户。如果您已注册 AWS Organizations，请使用以下步骤使用 Organizations 来启用和管理成员账户，而不是使用手动邀请流程：

1. [为组织指定 Detective 管理员账户。](#accounts-transition-designate-admin)这将创建组织行为图。

   如果 Detective 管理员账户已有行为图，则该行为图就会成为组织行为图。

1. [启用组织账户作为组织行为图中的成员账户。](#accounts-transition-members)

   如果组织行为图中现有的成员账户为组织账户，则这些账户会自动启用。

下图显示了过渡前的行为图结构、Organizations 中的配置和过渡后的行为图账户结构概述。

![\[此图表显示了在组织行为图中进行过渡 AWS Organizations 以用于管理成员帐户的过程。\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/images/diagram_account_transition.png)


## 为组织指定 Detective 管理员账户。
<a name="accounts-transition-designate-admin"></a>

组织管理账户指定了您所在组织的 Detective 管理员账户。请参阅[为组织指定 Detective 管理员](accounts-designate-admin.md)。

为了简化过渡，Detective 建议选择当前的管理员账户作为该组织的 Detective 管理员账户。

如果 Organizations 中有 Detective 的授权管理员账户，则必须使用该账户或组织管理账户作为 Detective 管理员账户。

否则，首次指定一个非组织管理账户的 Detective 管理员账户时，Detective 会调用 Organizations，将该账户设为 Detective 的授权管理员账户。

## 启用组织账户作为成员账户
<a name="accounts-transition-members"></a>

Detective 管理员账户是组织行为图的管理员账户。Detective 管理员账户在组织行为图中选择要作为成员账户启用的组织账户。请参阅[以 Detective 成员账户的身份管理组织账户](accounts-orgs-members.md)。

在**账户**页面，Detective 管理员账户可以访问所有组织账户。

如果 Detective 管理员账户已经是某个行为图的管理员账户，则该行为图就会成为组织行为图。在该行为图中已是成员账户的组织账户会自动启用为成员账户。其他组织账户的状态为**非成员**。

组织账户的类型为**按组织**，即使它们以前是按邀请的成员账户也是如此。

不属于该组织的成员账户的类型为**按邀请**。

**账户管理**页面还提供了**自动启用新组织账户**选项，可在新账户添加到组织时自动启用。请参阅[启用新的组织账户作为 Detective 成员账户](accounts-orgs-members-autoenable.md)。该选项最初处于关闭状态。

Detective 管理员账户首次显示**账户管理**页面时，会显示一条包含**启用所有组织账户**按钮的消息。选择**启用所有组织账户**时，Detective 会执行以下操作：
+ 启用所有当前组织账户作为成员账户。
+ 打开自动启用新组织账户的选项。

成员账户列表中还有一个**启用所有组织账户**选项。

# 为组织指定 Detective 管理员
<a name="accounts-designate-admin"></a>

在组织行为图中，Detective 管理员账户管理所有组织账户的行为图成员资格。

如何管理 Detective 管理员帐户-组织管理帐户为每个 AWS 区域组织指定侦探管理员帐户。

将 Detective 管理员帐户设置为委托管理员帐户 — Detective 管理员帐户也将成为 Detective 的委托管理员帐户 AWS Organizations。如果组织管理账户将自己指定为 Detective 管理员账户，则属于例外情况。组织管理账户不能是 Organizations 中的委托管理员。

在 Organizations 中设置委托管理员账户后，组织管理账户只能选择委托管理员账户或自己的账户作为 Detective 管理员账户。我们建议在所有区域选择委托管理员账户。

创建和管理组织行为图 — 当组织管理帐户选择 Detective 管理员帐户时，Detective 会为该帐户创建一个新的行为图表。该行为图就是组织行为图。

如果 Detective 管理员账户是现有行为图的管理员账户，则该行为图就会成为组织行为图。

Detective 管理员账户在组织行为图中选择要作为成员账户启用的组织账户。

![\[该图显示了组织管理账户如何选择 Detective 管理员账户。Detective 管理员账户是组织行为图的管理员账户，也是 Organizations 中的委托管理员账户。Detective 管理员账户可以访问所有组织账户。\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/images/diagram_account_delegation.png)


Detective 管理员账户还可以向不属于该组织的账户发送邀请。有关更多信息，请参阅[以 Detective 成员账户的身份管理组织账户](accounts-orgs-members.md)和[在 Detective 中管理受邀成员账户](accounts-invited-members.md)。

配置 Detective 管理员账户所需的权限 — 为确保组织管理账户能够配置 Detective 管理员账户，您可以将[`AmazonDetectiveOrganizationsAccess`托管策略](security-iam-awsmanpol.md#security-iam-awsmanpol-amazondetectiveorganizationsaccesspolicy)附加到您的 AWS Identity and Access Management (IAM) 实体。

# 指定 Detective 管理员
<a name="accounts-designate-admin-console"></a>

组织管理账户可以使用 Detective 控制台来指定 Detective 管理员账户。

要管理 Detective 管理员账户，无需启用 Detective。您可以从**启用 Detective** 页面管理 Detective 管理员账户。

------
#### [ Enable Detective page (Console) ]

要从 “**启用侦探**” 页面指定 Detective 管理员，请按照以下步骤操作。

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 选择**开始**。

1. 在**管理员账户所需权限**面板中，为选择的账户授予必要的权限，使其能够作为 Detective 管理员的身份进行操作，并完全有权访问 Detective 中的所有操作。要以管理员身份进行操作，我们建议将 `AmazonDetectiveFullAccess` 策略附加到主体。

1. 选择**从 IAM 附加策略**，直接在 IAM 控制台中查看推荐的策略。

1. 根据在 IAM 控制台中是否拥有权限，请按以下步骤操作：
   + 如果您有权在 IAM 控制台中进行操作，请将推荐的策略附加到用于 Detective 的主体。
   + 如果您无权在 IAM 控制台中进行操作，请复制策略的 Amazon 资源名称 (ARN) 并提供给 IAM 管理员。然后，他们就可以代表您附加策略。

1.  在**委托管理员**下，选择 Detective 管理员账户。

   可用的选项取决于是否拥有 Detective in Organizations 的委托管理员账户。
   + 如果您没有 Detective in Organizations 的委托管理员账户，请输入该账户的账户标识符，将其指定为 Detective 管理员账户。

     您可能已经拥有管理员账户，并通过手动邀请程序获得了行为图。如果是这样，我们建议将该账户指定为 Detective 管理员账户。

     如果你在 Organizations for Amazon 或 Amaz GuardDuty on Macie 中有一个委托管理员账户，那么 Detective 会提示你选择其中一个账户。 AWS Security Hub CSPM也可以输入不同的账户。
   + 如果您拥有 Detective in Organizations 的委托管理员账户，则系统会提示选择该账户或您的账户。我们建议在所有区域选择委托管理员账户。

1. 选择**委托**。

如果已启用 Detective，或者是现有行为图中的成员账户，则可以从**常规**页面指定 Detective 管理员账户。

------
#### [ General page (Console) ]

要从 “**常规**” 页面指定 Detective 管理员，请按照以下步骤操作。

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中的**设置**下，选择**常规**。

1. 在**托管式策略**面板中，您可以进一步了解 Detective 支持的所有托管式策略。您可以根据希望用户在 Detective 中执行的操作，向账户授予必要的权限。要以管理员身份进行操作，我们建议将 `AmazonDetectiveFullAccess` 策略附加到主体。

1. 根据在 IAM 控制台中是否拥有权限，请按以下步骤操作：
   + 如果您有权在 IAM 控制台中进行操作，请将推荐的策略附加到用于 Detective 的主体。
   + 如果您无权在 IAM 控制台中进行操作，请复制策略的 Amazon 资源名称 (ARN) 并提供给 IAM 管理员。然后，他们就可以代表您附加策略。

   可用的选项取决于是否拥有 Detective in Organizations 的委托管理员账户。
   + 如果您没有 Detective in Organizations 的委托管理员账户，请输入该账户的账户标识符，将其指定为 Detective 管理员账户。

     您可能已经拥有管理员账户，并通过手动邀请程序获得了行为图。如果是这样，则我们建议将该账户指定为 Detective 管理员账户。

     如果你在 Organizations for Amazon 或 Amaz GuardDuty on Macie 中有一个委托管理员账户，那么 Detective 会提示你选择其中一个账户。 AWS Security Hub CSPM也可以输入不同的账户。
   + 如果您拥有 Detective in Organizations 的委托管理员账户，则系统会提示选择该账户或您的账户。我们建议在所有区域选择委托管理员账户。

1. 选择**委托**。

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

要指定 Detective 管理员账户，可以使用 API 调用或 AWS Command Line Interface。必须使用组织管理账户凭证。

如果已经拥有 Detective in Organizations 委托管理员账户，则必须选择该账户或您的账户，我们建议选择委托管理员账户。

**要指定 Detective 管理员帐户（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_EnableOrganizationAdminAccount.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_EnableOrganizationAdminAccount.html) 操作。必须提供 Detective 管理员账户的 AWS 账户标识符。要获取账户标识符，请执行 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListOrganizationAdminAccounts.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListOrganizationAdminAccounts.html) 操作。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/enable-organization-admin-account.html](https://docs.aws.amazon.com/cli/latest/reference/detective/enable-organization-admin-account.html) 命令。

  ```
  aws detective enable-organization-admin-account --account-id <admin account ID>
  ```

  **示例**

  ```
  aws detective enable-organization-admin-account --account-id 777788889999
  ```

------

# 删除 Detective 管理员账号
<a name="accounts-remove-admin-overview"></a>

组织管理账户可以删除区域中当前的 Detective 管理员账户。删除 Detective 管理员账户时，Detective 只会将其从当前区域中删除。它不会更改 Organizations 中的委托管理员账户。

当组织管理账户删除某个区域中的 Detective 管理员账户时，Detective 会删除组织行为图。已删除的 Detective 管理员账户已禁用 Detective。

要删除 Detective 当前的委托管理员账户，需要使用 Organizations API。删除 Detective in Organizations 委托管理员账户后，Detective 会删除所有委托管理员账户为 Detective 管理员账户的组织行为图。使用组织管理账户作为 Detective 管理员账户的组织行为图不会受到影响。

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

可以从 Detective 控制台删除 Detective 管理员账户。

删除 Detective 管理员账户后，将对该账户禁用 Detective，并删除组织行为图。仅在当前区域中删除 Detective 管理员账户。

**重要**  
删除 Detective 管理员账户不会影响 Organizations 中的委托管理员账户。

**要删除 Detective 管理员账户（**启用 Detective** 页面）**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 选择**开始**。

1. 在**授权管理员**下，选择**禁用 Amazon Detective**。

1. 在确认对话框中，输入 **disable**，然后选择**禁用 Amazon Detective**。

**要删除 Detective 管理员账户（**常规**页面）**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中的**设置**下，选择**常规**。

1. 在**授权管理员**下，选择**禁用 Amazon Detective**。

1. 在确认对话框中，输入 **disable**，然后选择**禁用 Amazon Detective**。

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

要删除 Detective 管理员账户，可以使用 API 调用或 AWS CLI。必须使用组织管理账户凭证。

删除 Detective 管理员账户后，将对该账户禁用 Detective，并删除组织行为图。

**重要**  
删除 Detective 管理员账户不会影响 Organizations 中的委托管理员账户。

**要移除 Detective 管理员账户（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_DisableOrganizationAdminAccount.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_DisableOrganizationAdminAccount.html) 操作。

  使用 Detective API 删除 Detective 管理员账户时，只能在发出 API 调用或命令的区域内删除该账户。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/disable-organization-admin-account.html](https://docs.aws.amazon.com/cli/latest/reference/detective/disable-organization-admin-account.html) 命令。

  ```
  aws detective disable-organization-admin-account
  ```

------

## 移除委派管理员账号
<a name="accounts-remove-admin-orgs-api"></a>

删除 Detective 管理员账户不会自动删除 Organizations 中的授权管理员账户。要删除 Detective 的授权管理员账户，可以使用 Organizations API。

删除授权管理员账户时，这会删除授权管理员账户为 Detective 管理员账户的所有组织行为图。它还会禁用这些区域中账户的 Detective 功能。

**移除委派的管理员账号（Organizations API， AWS CLI）**
+ **Organizations API：**使用 [https://docs.aws.amazon.com/organizations/latest/APIReference/API_DeregisterDelegatedAdministrator.html](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DeregisterDelegatedAdministrator.html) 操作。必须提供 Detective 管理员账户的账户标识符和 Detective 的服务主体，即 `detective.amazonaws.com`。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/organizations/deregister-delegated-administrator.html](https://docs.aws.amazon.com/cli/latest/reference/organizations/deregister-delegated-administrator.html) 命令。

  ```
  aws organizations deregister-delegated-administrator --account-id <Detective administrator account ID> --service-principal <Detective service principal>
  ```

  **示例**

  ```
  aws organizations deregister-delegated-administrator --account-id 777788889999 --service-principal detective.amazonaws.com
  ```

# 账户的可用操作
<a name="accounts-allowed-actions"></a>

管理员和成员账户可以访问以下 Detective 操作。表中的数值具有以下含义：
+ **任何**——该账户可对同一 Detective 管理员账户下的所有账户执行操作。
+ **自身**——该账户只能对自身的账户执行操作。
+ 破折号 (-)——该账户不能执行操作。

在组织行为图中，Detective 管理员账户决定将哪些组织账户启用为成员账户。他们可以配置 Detective 将新组织账户自动启用为成员账户，也可以手动启用组织账户。

管理员账户可以邀请账户成为行为图中的成员账户。当成员账户接受邀请并启用后，Amazon Detective 就会开始采集成员账户的数据并将其提取到行为图中。

对于组织行为图以外的行为图，所有成员账户都是受邀账户。

下表列出了管理员和成员账户的默认权限。您可以使用自定义IAM策略进一步限制对 Detective 特性和功能的访问。


|  操作  |  管理员账户（组织）  |  管理员账户（邀请）  |  成员（组织）  |  成员（邀请）  | 
| --- | --- | --- | --- | --- | 
|  查看账户  |  任何  |  任何  |  自身（查看管理员账户）  |  自身（查看管理员账户）  | 
|  删除成员账户  |  任何 已删除受邀账户 已解除组织账户关联  |  任何  |  –  |  自身  | 
|  添加或删除可选的数据来源包  |  任何（设置适用于所有成员账户）  |  任何（设置适用于所有成员账户）  |  –  |  –  | 
|  禁用 Detective  | 自身 |  自身  |  –  |  –  | 
|  查看行为图数据  |  任何  |  任何  |  –  |  –  | 
|  启用或禁用可选的数据来源包  |  全部  |  全部  |  –  |  –  | 

# 查看账户列表
<a name="accounts-view-list"></a>

管理员账户可以使用 Detective 控制台或 API 来查看账户列表。该列表可能包括：
+ 管理员账户邀请加入行为图的账户。这些账户的类型为**按邀请**。
+ 对于组织行为图，即组织中的所有账户。这些账户的类型为**按组织**。

结果不包括拒绝邀请或管理员账户已从行为图中删除的受邀成员账户。它仅包括具有以下状态的账户。

**正在验证**  
对于受邀账户，Detective 会在发送邀请之前验证账户的电子邮件地址。  
对于组织账户，Detective 正在验证该账户是否属于该组织。Detective 还会验证是否是 Detective 管理员账户启用了该账户。

**验证失败**  
验证失败。邀请未发送，或者组织账户未启用为成员。

**已邀请**  
适用于受邀账户。邀请已发送，但成员账户尚未回复。

**不是数字**  
组织行为图中的组织账户。该组织账户目前不是成员账户。它不会向组织行为图提供数据。

**已启用**  
对于受邀账户，成员账户接受邀请并向行为图提供数据。  
对于组织行为图中的组织账户，Detective 管理员账户会将该账户启用为成员账户。该账户向组织行为图提供数据。

**未启用**  
对于受邀账户，成员账户接受了邀请，但无法启用。  
对于组织行为图中的组织账户，Detective 管理员账户试图启用该账户，但无法启用。  
对于受邀账户，Detective 会检查成员账户的数量。行为图的最大成员账户数为 1200 个。如果行为图已经包含 1,200 个成员帐户，则无法启用新帐户。  
Detective 会检查你的数据量是否在侦探配额之内。流入行为图的数据量必须小于 Detective 允许的最大值。如果当前摄取的容量超过行为图数据量每天 10 TB 的限制，则 Detective 将不允许您添加其他成员帐户。

## 列出账户（控制台）
<a name="accounts-view-list-console"></a>

您可以使用 AWS 管理控制台 来查看和筛选您的账户列表。

**要显示账户列表（控制台）**

1. 登录到 AWS 管理控制台。然后打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在 Detective 导航窗格中，选择**账户管理**。

   成员账户列表包含以下账户：
   + 您的 账户
   + 您邀请向行为图提供数据的账户
   + 在组织行为图中，所有的组织账户

   对于每个账户，列表会显示以下信息：
   +  AWS 账户标识符。
   + 对于组织账户，即账户名称。
   + 账户类型（**按邀请**或**按组织**）。
   + 对于受邀账户，即账户根用户电子邮件地址。
   + 账户状态。
   + 账户的每日数据量。Detective 无法检索未启用为成员账户的账户的数据量。
   + 上次更新账户状态的日期。

可以使用表格顶部的选项卡，根据成员账户状态筛选列表。每个选项卡都显示匹配的成员账户数量。
+ 选择**全部**，查看所有成员账户。
+ 选择**已启用**可查看状态为**已启用**的账户。
+ 选择**未启用**可查看状态不是**已启用**的账户。

还可以在成员账户列表中添加其他筛选条件。

**要向行为图中的账户列表添加筛选器（控制台）**

1. 选择筛选器框。

1. 选择用于筛选列表的列。

1. 对于指定的列，选择要用于筛选的值。

1. 要删除筛选器，请选择右上角的 **x** 图标。

1. 要使用最新状态信息更新列表，请选择右上角的刷新图标。

## 列出你的会员账号（Detective API， AWS CLI）
<a name="accounts-view-list-api"></a>

您可以使用 API 调 AWS Command Line Interface 用或在行为图中查看成员账户列表。

要获取要在请求中使用的行为图的 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**要检索成员账户列表（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListMembers.html) 操作。要确定预期的行为图，请指定行为图 ARN。

  请注意，对于组织行为图，[https://docs.aws.amazon.com/detective/latest/APIReference/API_ListMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListMembers.html) 不会返回未启用为成员账户的组织账户或从行为图中解除关联的组织账户。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/list-members.html](https://docs.aws.amazon.com/cli/latest/reference/detective/list-members.html) 命令。

  ```
  aws detective list-members --graph-arn <behavior graph ARN>
  ```

  示例：

  ```
  aws detective list-members --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

**在行为图中检索有关特定成员账户的详细信息（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_GetMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_GetMembers.html) 操作。指定成员账户的行为图 ARN 和账户标识符列表。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/get-members.html](https://docs.aws.amazon.com/cli/latest/reference/detective/get-members.html) 命令。

  ```
  aws detective get-members --account-ids <member account IDs> --graph-arn <behavior graph ARN>
  ```

  示例：

  ```
  aws detective get-members --account-ids 444455556666 123456789012 --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

# 以 Detective 成员账户的身份管理组织账户
<a name="accounts-orgs-members"></a>

在组织行为图中，Detective 管理员账户决定将哪些组织账户启用为成员账户。默认情况下，新组织账户不会作为成员账户启用。他们的身份是**非成员**。Detective 管理员账户可以配置 Detective 在组织行为图中自动启用新组织账户作为成员账户。

Detective 管理员可以将 Detective 配置为自动启用新的组织帐户作为成员帐户。如果选择自动启用组织账户，则当新账户添加到组织时，Detective 就会开始将其作为成员账户启用。Detective 不会启用尚未启用的现有组织账户。

如果您不想自动启用新的组织帐户，Detective 可以手动启用组织帐户作为成员帐户。他们还可以手动启用已取消关联的组织帐户。如果组织行为图已经启用了最多 1,200 个帐户，则 Detective 管理员无法将组织帐户启用为成员帐户。在这种情况下，组织账户的状态仍为**非成员**。

Detective 管理员还可以取消组织帐户与组织行为图的关联。要停止从组织行为图中的组织账户摄取数据，可以解除与该账户的关联。该账户的现有数据将保留在行为图中。

**Topics**
+ [

# 启用新的组织账户作为 Detective 成员账户
](accounts-orgs-members-autoenable.md)
+ [

# 启用组织账户作为 Detective 成员账户
](accounts-orgs-members-enable.md)
+ [

# 取消组织账户与 Detective 成员账户的关联
](accounts-orgs-members-disassociate.md)

# 启用新的组织账户作为 Detective 成员账户
<a name="accounts-orgs-members-autoenable"></a>

Detective 管理员账户可以配置 Detective 在组织行为图中自动启用新组织账户作为成员账户。

新账户添加到组织后，它们会被添加到**账户管理**页面的列表中。对于组织账户，**类型**为**按组织**。

默认情况下，新组织账户不会作为成员账户启用。他们的身份是**非成员**。

如果选择自动启用组织账户，则当新账户添加到组织时，Detective 就会开始将其作为成员账户启用。Detective 不会启用尚未启用的现有组织账户。

只有当行为图的最大成员帐户数为 1,200 时，Detective 才能启用组织帐户作为成员帐户。如果行为图中已包含 1200 个成员账户，则无法启用新账户。

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

在**账户管理**页面上，**自动启用新组织账户**设置决定是否在账户被添加到组织时自动启用这些账户。

**要将新组织账户自动启用为成员账户**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 将**自动启用新组织账户**切换到开启位置。

------
#### [ DetectiveAPI/AWS CLI ]

要确定是否自动启用新的组织帐户作为 Detective 成员帐户，管理员帐户可以使用 Detective API 或 AWS Command Line Interface。

要查看和管理配置，必须提供行为图 ARN。要获取 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**要查看自动启用组织账户的当前配置**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_DescribeOrganizationConfiguration.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_DescribeOrganizationConfiguration.html) 操作。

  在回复中，如果自动启用了新组织账户，则 `AutoEnable` 为 `true`。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/describe-organization-configuration.html](https://docs.aws.amazon.com/cli/latest/reference/detective/describe-organization-configuration.html) 命令。

  ```
  aws detective describe-organization-configuration --graph-arn <behavior graph ARN>
  ```

  **示例**

  ```
  aws detective describe-organization-configuration --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

**要自动启用新组织账户**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_UpdateOrganizationConfiguration.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_UpdateOrganizationConfiguration.html) 操作。要自动启用新组织账户，请将 `AutoEnable` 设置为 `true`。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/update-organization-configuration.html](https://docs.aws.amazon.com/cli/latest/reference/detective/update-organization-configuration.html) 命令。

  ```
  aws detective update-organization-configuration --graph-arn <behavior graph ARN> --auto-enable | --no-auto-enable
  ```

  示例

  ```
  aws detective update-organization-configuration --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234 --auto-enable
  ```

------

# 启用组织账户作为 Detective 成员账户
<a name="accounts-orgs-members-enable"></a>

如果您没有自动启用新组织账户，则可以手动启用这些账户。您还必须手动启用已解除关联的账户。

## 确定是否可以启用账户
<a name="accounts-orgs-members-enable-eligibility"></a>

如果组织行为图中已启用账户的上限为 1200 个，则无法将组织账户启用为成员账户。在这种情况下，组织账户的状态仍为**非成员**。该账户不向行为图提供数据。

一旦成员账户可以启用，Detective 就会自动将成员账户状态更改为**已启用**。例如，如果管理员帐户删除其他成员帐户以便为帐户腾出空间，则成员帐户的状态将更改为 “**已启用**”。

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

在**账户管理**页面，可以将组织账户作为成员账户启用。

**要启用组织账户作为成员账户**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 要查看当前未启用的账户列表，请选择**未启用**。

1. 您可以选择特定的组织账户，也可以启用所有组织账户。

   要启用选定的组织账户：

   1. 选择要启用的每个组织账户。

   1. 选择**启用账户**。

   要启用所有组织账户，请选择**启用所有组织账户**。

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

您可以使用 Detective API 或在组织行为图中启用组织账户作为成员账户。 AWS Command Line Interface 要获取要在请求中使用的行为图的 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**要启用组织账户作为成员账户**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_CreateMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_CreateMembers.html) 操作。您必须提供图 ARN。

  为每个账户指定账户标识符。组织行为图中的组织账户不会收到邀请。您无需提供电子邮件地址或其他邀请信息。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/create-members.html](https://docs.aws.amazon.com/cli/latest/reference/detective/create-members.html) 命令。

  ```
  aws detective create-members --accounts AccountId=<AWS account ID> --graph-arn <behavior graph ARN>
  ```

  **示例**

  ```
  aws detective create-members --accounts AccountId=444455556666 AccountId=123456789012 --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

------

# 取消组织账户与 Detective 成员账户的关联
<a name="accounts-orgs-members-disassociate"></a>

要停止从组织行为图中的组织账户摄取数据，可以解除与该账户的关联。该账户的现有数据将保留在行为图中。

取消关联组织成员账户后，该账户的状态将更改为 “**非成员**”。Detective 不再将来自该账户的数据提取到你的行为图中。该账户的现有数据仍保留在行为图中，该账户仍保留在列表中。

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

在**账户管理**页面，您可以解除组织账户作为成员账户的关联。要解除组织账户作为成员账户的关联（控制台）

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 要显示已启用的账户列表，请选择**已启用**。

1. 选择要解除关联的每个账户的复选框。

1. 选择**操作**。然后选择**禁用账户**。

   已解除关联账户的账户状态更改为**非成员**。

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

要获取要在请求中使用的行为图的 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**取消组织账户与组织行为图的关联**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_DeleteMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_DeleteMembers.html) 操作。指定要解除关联的成员账户的图 ARN 和账户标识符列表。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/delete-members.html](https://docs.aws.amazon.com/cli/latest/reference/detective/delete-members.html) 命令。

  ```
  aws detective delete-members --account-ids <account ID list> --graph-arn <behavior graph ARN>
  ```

  **示例**

  ```
  aws detective delete-members --account-ids 444455556666 123456789012 --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

------

# 在 Detective 中管理受邀成员账户
<a name="accounts-invited-members"></a>

Detective 管理员账户可以在其行为图中邀请账户成为成员账户。一张行为图最多可以包含 1200 个成员账户。当成员账户接受邀请并启用后，Amazon Detective 就会开始采集成员账户的数据并将其提取到行为图中。

要邀请个人帐户，您可以手动指定要邀请的成员帐户将其数据贡献到行为图中。如果要添加成员账户列表，可以选择提供一个.csv 文件，其中包含要邀请加入行为图的成员账户列表。

对于组织行为图以外的行为图，所有成员账户都是受邀账户。Detective 管理员账户也可以邀请非组织账户的账户加入组织行为图。

简而言之，邀请账户加入行为图的流程如下。

1. 对于要添加的每个成员帐户，管理员帐户都提供 AWS 账户标识符和根用户电子邮件地址。

1. Detective 验证此电子邮件地址是否为账户的根用户电子邮件地址。如果账户信息有效，Detective 就会向成员账户发送邀请。

   Detective 不会执行此验证或向以下地区的成员账户发送电子邮件邀请：
   + AWS GovCloud （美国东部）区域
   + AWS GovCloud （美国西部）区域

   对于其他区域，你可以`DisableEmailNotification`使用 Detective API 的[CreateMembers](https://docs.aws.amazon.com//detective/latest/APIReference/API_CreateMembers.html)操作。如果设置`DisableEmailNotification`为 true，则 Detective 将不会向成员账户发送邀请。对于集中管理的账户，这是一个有用的设置。

1. 成员账户接受或拒绝邀请。

   即使管理员账户不发送邀请电子邮件，成员账户也必须回复邀请。

1. 成员账户接受邀请后，Detective 开始将成员账户中的数据提取到行为图中。

1. 一旦成员账户符合启用条件，Detective 就会自动将成员账户状态更改为**已启用**。

   例如，如果管理员帐户删除其他成员帐户以便为帐户腾出空间，则成员帐户的状态将更改为 “**启用**”。

   如果多个账户处于**未启用**状态，则 Detective 会按照邀请顺序启用这些账户。检查是否启用任何**未启用**账户的程序每小时运行一次。

   管理员账户还可以手动启用账户，而不必等待自动流程。例如，管理员账户可能想要选择要启用的账户。有关如何启用成员账户的信息，请参阅[启用未启用的成员账户](graph-admin-unblock-account.md)。

   请注意，Detective 于 2021 年 5 月 12 日开始自动启用**未启用**的账户。在此之前**未启用**的账户不会自动启用。管理员账户必须手动启用它们。

管理员账户可以从行为图中删除受邀成员账户。Detective 不会从行为图中删除任何现有数据，因为行为图汇总了各成员账户的数据。

**Topics**
+ [

# 邀请个人账号加入行为图表
](accounts-invited-members-add-individual.md)
+ [

# 邀请成员账号列表加入行为图表
](accounts-invited-members-add-csv.md)
+ [

# 启用未启用的成员账户
](graph-admin-unblock-account.md)
+ [

# 从行为图中移除成员账户
](accounts-invited-remove.md)

# 邀请个人账号加入行为图表
<a name="accounts-invited-members-add-individual"></a>

可以手动指定要邀请为行为图提供数据的成员账户。

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

**使用 Detective 控制台手动选择要邀请的成员账户。**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 选择**操作**。然后选择**邀请账户**。

1. 在**添加账户**下，选择**添加个人账户**。

1. 要将成员账户添加到邀请列表，请执行以下步骤。

   1. 选择**添加账户**。

   1. 在**AWS 账户 ID** 中，输入 AWS 账户 ID。

   1. 对于**电子邮件地址**，输入根用户账户的电子邮件地址。

1. 要从列表中删除某个账户，请为该账户选择**删除**。

1. 在**个性化邀请电子邮件**下，添加要包含在邀请电子邮件中的自定义内容。

   例如，可以使用该区域提供联系信息。或者使用它来提醒成员账户，他们需要将所需的 IAM 策略附加到其用户或角色，然后才能接受邀请。

1. **成员账户 IAM 策略**包含成员账户所需 IAM 策略的文本。电子邮件邀请中包含此策略文本。要复制策略文本，请选择**复制**。

1. 选择**邀请**。

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

你可以使用 Detective API 或 AWS Command Line Interface 邀请成员账号将其数据贡献到行为图中。要获取要在请求中使用的行为图的 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**邀请成员账号访问行为图（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_CreateMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_CreateMembers.html) 操作。您必须提供图 ARN。为每个账户指定账户标识符和根用户电子邮件地址。

  如果不想向成员账户发送邀请电子邮件，请将 `DisableEmailNotification` 设置为 true。默认 `DisableEmailNotification` 为 false。

  如果要发送邀请电子邮件，则可以选择提供自定义文本添加到邀请电子邮件中。
+ **AWS CLI：**在命令行处，运行 `create-members` 命令。

  ```
  aws detective create-members --accounts AccountId=<AWS account ID>,EmailAddress=<root user email address> --graph-arn <behavior graph ARN> --message "<Custom message text>"
  ```

  **示例**

  ```
  aws detective create-members --accounts AccountId=444455556666,EmailAddress=mmajor@example.com AccountId=123456789012,EmailAddress=jstiles@example.com --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234 --message "This is Paul Santos. I need to add your account to the data we use for security investigation in Amazon Detective. If you have any questions, contact me at psantos@example.com."
  ```

  要表示不向成员账户发送邀请电子邮件，请包含`--disable-email-notification`。

  ```
  aws detective create-members --accounts AccountId=<AWS account ID>,EmailAddress=<root user email address> --graph-arn <behavior graph ARN> --disable-email-notification
  ```

  **示例**

  ```
  aws detective create-members --accounts AccountId=444455556666,EmailAddress=mmajor@example.com AccountId=123456789012,EmailAddress=jstiles@example.com --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234 --disable-email-notification
  ```

------

# 邀请成员账号列表加入行为图表
<a name="accounts-invited-members-add-csv"></a>

可以从 Detective 控制台提供一份 `.csv` 文件，其中包含要邀请加入行为图的成员账户列表。

文件的第一行是标题行。然后将每个账户单独列一行。每个成员账户条目都包含 AWS 账户 ID 和账户的 root 用户电子邮件地址。

示例：

```
Account ID,Email address
111122223333,srodriguez@example.com
444455556666,rroe@example.com
```

Detective 在处理文件时，会忽略已邀请的账户，除非账户状态为**验证失败**。该状态表明，为该账户提供的电子邮件地址与该账户根用户电子邮件地址不匹配。在这种情况下，Detective 会删除原始邀请，然后再次尝试验证电子邮件地址并发送邀请。

该选项还提供了可用于创建账户列表的模板。

**从 .csv 列表（控制台）邀请成员账户**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 选择**操作**。然后选择**邀请账户**。

1. 在**添加账户**下，选择**从 .csv 添加**。

1. 要下载要使用的模板文件，请选择**下载 .csv 模板**。

1. 要选择包含账户列表的文件，请选择**选择 .csv 文件**。

1. 在**查看成员账户**下，验证 Detective 在文件中检测到的成员账户列表。

1. 在**个性化邀请电子邮件**下，添加要包含在邀请电子邮件中的自定义内容。

   例如，可以提供联系信息，或提醒成员账户注意所需的 IAM 策略。

1. **成员账户 IAM 策略**包含成员账户所需 IAM 策略的文本。电子邮件邀请中包含此策略文本。要复制策略文本，请选择**复制**。

1. 选择**邀请**。

## 添加跨区域的成员账户列表
<a name="accounts-invited-add-script"></a>

Detective 在中 GitHub 提供了一个开源 Python 脚本，允许你执行以下操作：
+ 在指定的区域列表中，将指定的成员账户列表添加到管理员账户的行为图中。
+ 如果管理员账户在某个区域中没有行为图，则该脚本也会启用 Detective 并在该区域中创建行为图。
+ 向成员账号发送邀请电子邮件。
+ 自动接受成员账户的邀请。

有关如何配置和使用 GitHub 脚本的信息，请参阅[使用 Detective Python 脚本管理账户](detective-github-scripts.md)。

# 启用未启用的成员账户
<a name="graph-admin-unblock-account"></a>

会员账户接受邀请后，Amazon Detective 会检查成员账户的数量。行为图的最大成员账户数为 1200 个。如果行为图中已包含 1200 个成员账户，则无法启用新账户。如果 Detective 无法启用成员账户，则会将成员账户状态设置为**未启用**。

**未启用**的成员账户不会为行为图提供数据。

Detective 会根据行为图自动启用账户。

也可以尝试手动启用**未启用**成员账户的成员账户。例如，可以删除现有的成员账户，以减少数据量。与其等待自动程序启用账户，不如尝试启用**未启用**的成员账户。

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

成员账户列表包含一个选项，可启用**未启用**的选定成员账户。

**要启用未启用的成员账户**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 在**我的成员账户**下，选中要启用的每个成员账户对应的复选框。

   只能启用状态为**未启用**的成员账户。

1. 选择**启用账户**。

Detective 决定是否可以启用成员账户。如果可以启用成员账户，则状态将更改为**已启用**。

------
#### [ Detective API/CLI ]

您可以使用 API 调 AWS Command Line Interface 用或**启用未启用的**单个成员账户。要获取要在请求中使用的行为图的 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**要启用未启用的成员账户**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_StartMonitoringMember.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_StartMonitoringMember.html) API 操作。必须提供行为图 ARN。要识别成员账户，请使用 AWS 账户标识符。
+ **AWS CLI:** 运行[https://docs.aws.amazon.com/cli/latest/reference/detective/start-monitoring-member.html](https://docs.aws.amazon.com/cli/latest/reference/detective/start-monitoring-member.html)命令。

  ```
  start-monitoring-member --graph-arn <behavior graph ARN> --account-id <AWS account ID>
  ```

  例如：

  ```
  start-monitoring-member --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234 --account-id 444455556666
  ```

------

# 从行为图中移除成员账户
<a name="accounts-invited-remove"></a>

管理员账户可以随时从行为图中删除受邀成员账户。

Detective 会自动删除终止于 AWS AWS GovCloud （美国东部）和 AWS GovCloud （美国西部）地区的成员账户。

从行为图中删除受邀成员账户时，会发生以下情况。
+ 该成员账户已从**我的成员账户**中删除。
+ Amazon Detective 会停止从已删除的账户提取数据。

Detective 不会从行为图中删除任何现有数据，因为行为图汇总了各成员账户的数据。

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

您可以使用 AWS 管理控制台 将受邀成员账户从行为图中移除。

**要删除成员账户（控制台）**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 在账户列表中，选择要删除的每个成员账户的复选框。

   无法从列表中删除自己的账户。

1. 选择**操作**。然后选择**禁用账户**。

------
#### [ Detective API/CLI  ]

你可以使用 Detective API 或 AWS Command Line Interface 将受邀成员账户从行为图中移除。要获取要在请求中使用的行为图的 ARN，请使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListGraphs.html) 操作。

**从行为图中移除受邀成员账号（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_DeleteMembers.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_DeleteMembers.html) 操作。指定要删除的成员账户的图 ARN 和账户标识符列表。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/delete-members.html](https://docs.aws.amazon.com/cli/latest/reference/detective/delete-members.html) 命令。

  ```
  aws detective delete-members --account-ids <account ID list> --graph-arn <behavior graph ARN>
  ```

  示例：

  ```
  aws detective delete-members --account-ids 444455556666 123456789012 --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

------
#### [ Python script ]

Detective 在中提供了一个开源脚本 GitHub。可以使用此脚本从管理员账户的行为图表中删除指定区域列表中的指定成员账户列表。

有关如何配置和使用 GitHub 脚本的信息，请参阅[使用 Detective Python 脚本管理账户](detective-github-scripts.md)。

------

# 对于成员账号：管理行为图邀请和成员资格
<a name="member-account-graph-management"></a>

Amazon Detective 会向每个成员账户摄取其提供的每个行为图所摄取的数据费用。

**账户管理**页面允许成员账户查看其所属的行为图的管理员账户。

受邀访问行为图的成员账号可以查看和回复他们的邀请。他们还可以从行为图中删除自己的账户。

对于组织行为图，组织账户无法控制其账户是否为成员账户。Detective 管理员账户可选择启用或禁用组织账户作为成员账户。

**Topics**
+ [

# 成员账户所需的 IAM 策略
](member-account-iam-policy.md)
+ [

# 查看行为图邀请列表
](member-view-graph-invitations.md)
+ [

# 回复行为图邀请
](member-invitation-response.md)
+ [

# 从行为图中删除账户
](member-remove-self-from-graph.md)

# 成员账户所需的 IAM 策略
<a name="member-account-iam-policy"></a>

在成员账户可以查看和管理邀请之前，必须将所需的 IAM 策略附加到其主体。主体可以是现有用户或角色，也可以创建新的用户或角色供 Detective 使用。

理想情况下，管理员账户的 IAM 管理员会附加所需的策略。

成员账户 IAM 策略允许访问 Amazon Detective 中的成员账户操作。行为图的电子邮件邀请包括该 IAM 策略的文本。

要使用此策略，请将`<behavior graph ARN>`替换为图 ARN。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "detective:AcceptInvitation",
        "detective:DisassociateMembership",
        "detective:RejectInvitation"
      ],
      "Resource": "arn:aws:detective:us-east-1:123456789012:graph/*"
    },
   {
    "Effect":"Allow",
    "Action":[
        "detective:BatchGetMembershipDatasources",
        "detective:GetFreeTrialEligibility",
        "detective:GetPricingInformation",
        "detective:GetUsageInformation",
        "detective:ListInvitations"
    ],
    "Resource":"*"
   }
 ]
}
```

------

请注意，组织行为图中的组织账户不会收到邀请，也无法取消其账户与组织行为图的关联。如果它们不属于其他行为图，则只需获得 `ListInvitations` 权限。`ListInvitations` 允许他们查看行为图的管理员账户。管理邀请和取消关联成员资格的权限仅适用于通过邀请获得的成员资格。

# 查看行为图邀请列表
<a name="member-view-graph-invitations"></a>

通过 Amazon Detective 控制台、Detective API 或者 AWS Command Line Interface，会员账户可以看到他们的行为图表邀请。

## 查看行为图邀请（控制台）
<a name="member-view-invitations-console"></a>

您可以从中查看行为图邀请 AWS 管理控制台。

**要查看行为图邀请（控制台）**

1. 登录到 AWS 管理控制台。然后打开 Detective 控制台，网址为[https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/)。

1. 在 Detective 导航窗格中，选择**账户管理**。

在**账户管理**页面上，**我的管理员账户**包含在当前区域中已打开和已接受的行为图邀请。对于组织账户，**我的管理员账户**还包含组织行为图。

如果账户目前处于免费试用期，该页面还会显示免费试用期的剩余天数。

该列表中不包含拒绝的邀请、退出的成员资格或管理员账户删除的成员资格。

每个邀请都会显示管理员账号、接受邀请的日期以及邀请的当前状态。
+ 对于尚未回复的邀请，状态为**已邀请**。
+ 对于已接受的邀请，状态为**已启用**或**未启用**。

  如果状态为**已启用**，则账户会向行为图提供数据。

  如果状态为**未启用**，则账户不会向行为图提供数据。

  您的账户状态最初设置为 “**未启用”**，而 Detective 会检查您是否已 GuardDuty 启用，如果启用，则检查您的账户是否会导致行为图的数据量超过 Detective 配额。

  如果账户不会导致行为图超出配额，Detective 会将账户状态更新为**已启用**。否则，状态将保持为**未启用**。

  当行为图能够容纳账户的数据量时，Detective 会自动将其更新为**已启用**。例如，管理员账户可能会删除其他成员账户，以便启用账户。管理员账户也可以手动启用账户。

## 查看行为图邀请（Detective API， AWS CLI）
<a name="member-view-invitations-api"></a>

您可以通过 Detective API 或 AWS Command Line Interface列出行为图邀请。

**检索行为图的开放和已接受邀请列表（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_ListInvitations.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_ListInvitations.html) 操作。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/list-invitations.html](https://docs.aws.amazon.com/cli/latest/reference/detective/list-invitations.html) 命令。

  ```
  aws detective list-invitations
  ```

# 回复行为图邀请
<a name="member-invitation-response"></a>

在你接受邀请后，Detective 会检查成员账户的数量。行为图的最大成员账户数为 1200 个。如果行为图中已包含 1200 个成员账户，则无法启用新账户。

接受邀请后，您的帐户中将启用 Detective。Detective 会检查你的数据量是否在侦探配额之内。流入行为图的数据量必须小于 Detective 允许的最大值。如果当前摄取的容量高于每天 10 TB 的限制，则无法添加更多帐户，Detective 将禁止进一步摄取数据。Detective 控制台会显示一条通知，指出数据量太大且状态仍为 “**未启用”**。

如果拒绝邀请，则该邀请就会从邀请列表中删除，Detective 也不会在行为图中使用账户数据。

## 回复行为图邀请（控制台）
<a name="member-invitation-response-console"></a>

您可以使用回复电子邮件邀请，其中包括指向 Detective 控制台的链接。 AWS 管理控制台 只能回复状态为**已邀请**的邀请。

**要回复行为图邀请（控制台）**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 在**我的管理员账户**下，要接受邀请并开始向行为图提供数据，请选择**接受邀请**。

   要拒绝邀请并将其从列表中删除，请选择**拒绝**。

## 回应行为图邀请（Detective API， AWS CLI）
<a name="member-invitation-response-api"></a>

您可以通过 Detective API 或 AWS Command Line Interface回复行为图邀请。

**接受行为图邀请（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_AcceptInvitation.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_AcceptInvitation.html) 操作。您必须指定图 ARN。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/accept-invitation.html](https://docs.aws.amazon.com/cli/latest/reference/detective/accept-invitation.html) 命令。

  ```
  aws detective accept-invitation --graph-arn <behavior graph ARN>
  ```

  示例：

  ```
  aws detective accept-invitation --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

**要拒绝行为图邀请（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_RejectInvitation.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_RejectInvitation.html) 操作。您必须指定图 ARN。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/reject-invitation.html](https://docs.aws.amazon.com/cli/latest/reference/detective/reject-invitation.html) 命令。

  ```
  aws detective reject-invitation --graph-arn <behavior graph ARN>
  ```

  示例：

  ```
  aws detective reject-invitation --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

# 从行为图中删除账户
<a name="member-remove-self-from-graph"></a>

接受邀请后，可以随时从行为图中删除账户。从行为图中删除账户时，Amazon Detective 会停止从账户向行为图中摄取数据。现有数据仍保留在行为图中。

只有受邀账户才能从行为图中删除自己的账户。组织账户不能从组织行为图中删除自己的账户。

## 从行为图中删除账户（控制台）
<a name="member-remove-self-console"></a>

您可以使用 AWS 管理控制台 将您的账户从行为图表中移除。

**要从行为图中删除账户（控制台）**

1. 通过 [https://console.aws.amazon.com/detective/](https://console.aws.amazon.com/detective/) 打开 Amazon Detective 控制台。

1. 在 Detective 导航窗格中，选择**账户管理**。

1. 在**我的管理员账户**下，针对要退出的行为图，选择**退出**。

## 从行为图中删除你的账户（Detective API， AWS CLI）
<a name="member-remove-self-api"></a>

你可以使用 Detective API 或 AWS Command Line Interface 将你的账户从行为图中移除。

**要将你的账号从行为图中移除（Detective API， AWS CLI）**
+ **Detective API：**使用 [https://docs.aws.amazon.com/detective/latest/APIReference/API_DisassociateMembership.html](https://docs.aws.amazon.com/detective/latest/APIReference/API_DisassociateMembership.html) 操作。您必须指定图 ARN。
+ **AWS CLI：**在命令行处，运行 [https://docs.aws.amazon.com/cli/latest/reference/detective/disassociate-membership.html](https://docs.aws.amazon.com/cli/latest/reference/detective/disassociate-membership.html) 命令。

  ```
  aws detective disassociate-membership --graph-arn <behavior graph ARN>
  ```

  示例：

  ```
  aws detective disassociate-membership --graph-arn arn:aws:detective:us-east-1:111122223333:graph:123412341234
  ```

# 账户操作对行为图的影响
<a name="accounts-effects"></a>

这些操作会对 Amazon Detective 的数据和访问产生以下影响。

## Detective 已禁用
<a name="accounts-effects-detective-disabled"></a>

当管理员账户禁用 Detective 时，会出现以下情况：
+ 删除行为图。
+ Detective 停止从管理员账户和该行为图的成员账户中摄取数据。

## 成员账户已从行为图中删除
<a name="accounts-effects-member-removed"></a>

从行为图中删除成员账户后，Detective 会停止从该账户摄取数据。

行为图中的现有数据不受影响。

对于受邀账户，该账户将从**我的成员账户**列表中删除。

对于组织行为图中的组织账户，账户状态更改为**非成员**。

## 成员账户退出组织
<a name="accounts-effects-member-leaves-org"></a>

当成员账户退出组织时，会发生以下情况：
+ 该账户已从组织行为图的**我的成员账户**列表中删除。
+ Detective 会停止从该账户摄取数据。

行为图中的现有数据不受影响。

## AWS 账户已暂停
<a name="accounts-effects-account-suspended"></a>

管理员帐户在中被暂停后 AWS，该帐户将失去在 Detective 中查看行为图的权限。Detective 停止向行为图输入数据。

当会员帐户在中被暂停时 AWS，Detective 会停止提取该帐户的数据。

90 天后，该账户将被停用或重新激活。管理员账户被重新激活后，其 Detective 权限将恢复。Detective 会恢复从该账户摄取数据。成员账户被重新激活后，Detective 会恢复从该账户中摄取数据。

## AWS 账户已关闭
<a name="accounts-effects-account-closed"></a>

 AWS 账户关闭后，Detective 会对关闭做出如下回应。
+ 对于管理员账户，Detective 会删除行为图。
+ 对于成员账户，Detective 会将该账户从行为图中删除。

 AWS 自管理员账户关闭生效之日起，将账户的政策数据保留 90 天。在 90 天期限结束时， AWS 永久删除该账户的所有保单数据。
+  要将调查发现保留 90 天以上，可以将策略存档。您还可以使用带有 EventBridge 规则的自定义操作将发现结果存储在 S3 存储桶中。
+  只要 AWS 保留策略数据，当您重新打开已关闭的账户时，就会将该账户重新 AWS 分配为服务管理员并恢复该账户的服务策略数据。
+  有关更多信息，请参阅[关闭账户](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/close-account.html)。

**重要**  
 对于 AWS GovCloud (US) 各地区的客户：  
 在关闭账户前，备份并删除账户资源。关闭账户后，将不再拥有其访问权限。

# 使用 Detective Python 脚本管理账户
<a name="detective-github-scripts"></a>

Amazon Detective 在 GitHub 存储库中提供了一组开源 Python 脚本[amazon-detective-multiaccount-scripts](https://github.com/aws-samples/amazon-detective-multiaccount-scripts)。这些脚本需要 Python 3。

您可以使用它们执行以下任务：
+ 启用跨区域的管理员账户 Detective。

  启用 Detective 后，您就可以向行为图分配标签值。
+ 在跨区域中，将成员账户添加到管理员账户的行为图中。
+ 可选择向成员账号发送邀请电子邮件。您还可以将请求配置为不发送邀请电子邮件。
+ 在跨区域中，从管理员账户的行为图中删除成员账户。
+ 禁用跨区域的管理员账户 Detective。当管理员账户禁用 Detective 时，每个区域中管理员账户的行为图都会被禁用。

## `enableDetective.py` 脚本概述
<a name="enabledetective-script-overview"></a>

`enableDetective.py` 脚本执行以下操作：

1. 在每个指定区域为管理员账户启用 Detective，前提是该管理员账户尚未在该区域启用 Detective。

   使用脚本启用 Detective 后，您就可以向行为图分配标签值。

1. 可选择从管理员账户向每个行为图的指定成员账户发送邀请。

   邀请电子邮件消息使用默认消息内容，无法自定义。

   您还可以将请求配置为不发送邀请电子邮件。

1. 自动接受成员账户的邀请。

   由于脚本会自动接受邀请，因此成员账户可以忽略这些消息。

   我们建议直接联系成员账户，通知他们自动接受邀请。

## `disableDetective.py` 脚本概述
<a name="disabledetective-script-overview"></a>

`disableDetective.py` 脚本会删除指定区域内管理员账户行为图中的指定成员账户。

此外，还提供了在指定区域内禁用管理员账户 Detective 的选项。

## 脚本所需的权限
<a name="github-scripts-permissions"></a>

这些脚本需要管理员帐户以及您添加或删除的所有成员帐户中预先存在的 AWS 角色。

**注意**  
所有账户中的角色名称必须相同。

IAM 策略[推荐的最佳做法](https://docs.aws.amazon.com/detective/latest/userguide/security_iam_id-based-policy-examples.html#security_iam_service-with-iam-policy-best-practices)是使用范围最小的角色。要执行脚本中[创建图表](https://docs.aws.amazon.com/detective/latest/APIReference/API_CreateGraph.html)、[创建成员](https://docs.aws.amazon.com/detective/latest/APIReference/API_CreateMembers.html)和[向图中添加成员](https://docs.aws.amazon.com/detective/latest/APIReference/API_AcceptInvitation.html)的工作流程，所需的权限是：
+ 侦探：CreateGraph
+ 侦探：CreateMembers
+ 侦探：DeleteGraph
+ 侦探：DeleteMembers
+ 侦探：ListGraphs
+ 侦探：ListMembers
+ 侦探：AcceptInvitation

**角色信任关系**

角色信任关系必须允许实例或本地凭证代入该角色。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
            "AWS": "arn:aws:iam::123456789012:user/john_doe"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
```

------

如果您没有包含所需权限的通用角色，则必须在每个成员账户中创建一个至少具有这些权限的角色。您还必须在管理员账户中创建角色。

创建角色时，请确保执行以下操作：
+ 在每个账户中使用相同的角色名称。
+ 在上面添加所需的权限（推荐）或选择[AmazonDetectiveFullAccess](https://docs.aws.amazon.com/detective/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-amazondetectivefullaccess)托管策略。
+ 如上所述，添加角色信任关系模块。

要自动执行此过程，您可以使用`EnableDetective.yaml` CloudFormation 模板。由于该模板只创建全局资源，因此可以在任何区域运行。

## 为 Python 脚本设置运行环境
<a name="github-script-setup"></a>

您可以通过 EC2 实例或本地计算机运行脚本。

### 启动和配置 EC2 实例
<a name="github-setup-ec2-instance"></a>

运行脚本的一种方法是从 EC2 实例运行脚本。

**要启动和配置 EC2 实例**

1. 在管理员账户中启动 EC2 实例。有关如何启动 EC2 实例的详细信息，请参阅亚马逊 EC2 *用户指南*中的 [Amazon EC2 Linux 实例入门](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html)。

1. 为实例附加一个 IAM 角色，该角色拥有允许实例在管理员账户内调用 `AssumeRole` 的权限。

   如果您使用该`EnableDetective.yaml` CloudFormation 模板，则会创建配置文件名`EnableDetective`为的实例角色。

   否则，有关创建实例角色的信息，请参阅博客文章[使用 EC2 控制台轻松将 IAM 角色替换或附加到现有 EC2 实例](https://aws.amazon.com/blogs//security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/)。

1. 安装所需的软件：
   + **APT：**`sudo apt-get -y install python3-pip python3 git`
   + **RPM：**`sudo yum -y install python3-pip python3 git`
   + **Boto（最低版本 1.15）：**`sudo pip install boto3`

1. 将存储库克隆到 EC2 实例。

   ```
   git clone https://github.com/aws-samples/amazon-detective-multiaccount-scripts.git
   ```

### 配置本地计算机来运行脚本
<a name="github-setup-local-machine"></a>

您也可以在本地计算机上运行脚本。

**要配置本地计算机来运行脚本**

1. 确保已在本地计算机上设置了管理员账户凭证，该凭证具有调用 `AssumeRole` 的权限。

1. 安装所需的软件：
   + Python 3
   + Boto（最低版本 1.15）
   + GitHub 脚本    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/detective/latest/userguide/detective-github-scripts.html)

## 创建要添加或删除的 `.csv` 成员账户列表
<a name="github-scripts-csv-file"></a>

为确定要添加到行为图或从行为图中删除的成员账户，您需要提供一个包含账户列表的 `.csv` 文件。

将每个账户单独列一行。每个成员账户条目都包含 AWS 账户 ID 和账户的 root 用户电子邮件地址。

请参见以下示例：

```
111122223333,srodriguez@example.com
444455556666,rroe@example.com
```

## 运行 `enableDetective.py`
<a name="github-scripts-execute-enabledetective"></a>

您可以从 EC2 实例或本地计算机运行 `enableDetective.py` 脚本。

**运行 `enableDetective.py`**

1. 将 `.csv` 文件复制到 EC2 实例或本地计算机上的 `amazon-detective-multiaccount-scripts` 目录中。

1. 切换到 `amazon-detective-multiaccount-scripts` 目录。

1. 运行 `enableDetective.py` 脚本。

   ```
   enableDetective.py --master_account administratorAccountID --assume_role roleName --input_file inputFileName --tags tagValueList --enabled_regions regionList  --disable_email
   ```

运行脚本时，请替换以下值：

`administratorAccountID`  
管理员 AWS 账户的账户 ID。

`roleName`  
要在管理员账户和每个成员账户中 AWS 扮演的角色的名称。

`inputFileName`  
包含要添加到管理员账户行为图的成员账户列表的 `.csv` 文件的名称。

`tagValueList`  
（可选）以逗号分隔的标签值列表，用于为新行为图分配标签值。  
每个标签值的格式为 `key=value`。例如：  

```
--tags Department=Finance,Geo=Americas
```

`regionList`  
（可选）以逗号分隔的区域列表，用于将成员账户添加到管理员账户的行为图中。例如：  

```
--enabled_regions us-east-1,us-east-2,us-west-2
```
管理员账户可能尚未在某个区域中启用 Detective。在这种情况下，该脚本会启用 Detective 并为管理员账户创建新的行为图。  
如果您未提供区域列表，则该脚本将在 Detective 支持的所有区域内运行。

`--disable_email`  
（可选）如果包含，Detective 不会向成员账户发送邀请电子邮件。

## 运行 `disableDetective.py`
<a name="github-scripts-execute-disabledetective"></a>

您可以从 EC2 实例或本地计算机运行 `disableDetective.py` 脚本。

**运行 `disableDetective.py`**

1. 将 `.csv` 文件复制到 `amazon-detective-multiaccount-scripts` 目录。

1. 要使用 `.csv` 文件删除指定区域列表中管理员账户行为图中列出的成员账户，请按以下步骤运行 `disableDetective.py` 脚本：

   ```
   disabledetective.py --master_account administratorAccountID --assume_role roleName --input_file inputFileName --disabled_regions regionList
   ```

1. 要在所有区域禁用管理员账户的 Detective，请运行带有 `--delete-master` 标志的 `disableDetective.py` 脚本。

   ```
   disabledetective.py --master_account administratorAccountID --assume_role roleName --input_file inputFileName --disabled_regions regionList --delete_master
   ```

运行脚本时，请替换以下值：

`administratorAccountID`  
管理员 AWS 账户的账户 ID。

`roleName`  
要在管理员账户和每个成员账户中 AWS 扮演的角色的名称。

`inputFileName`  
包含要从管理员账户行为图中删除的成员账户列表的 `.csv` 文件的名称。  
即使禁用了 Detective，您也必须提供 `.csv` 文件。

`regionList`  
（可选）以逗号分隔的区域列表，用于执行以下操作之一：  
+ 从管理员账户的行为图中删除成员账户。
+ 如果包含 `--delete-master` 标志，请禁用 Detective。
例如：  

```
--disabled_regions us-east-1,us-east-2,us-west-2
```
如果您未提供区域列表，则该脚本将在 Detective 支持的所有区域内运行。