

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

# 管理 GuardDuty 安全代理
<a name="runtime-monitoring-managing-agents"></a>

您可以管理要监控的资源 GuardDuty 的安全代理。如果要监控多种资源类型，请务必管理该资源的 GuardDuty 代理。

以下主题有助您完成管理安全代理的后续步骤。

**Topics**
+ [为 Amazon EC2 实例启用自动安全代理](managing-gdu-agent-ec2-automated.md)
+ [手动管理 Amazon EC2 资源的安全代理](managing-gdu-agent-ec2-manually.md)
+ [管理 Fargate（仅限 Amazon ECS）的自动安全代理](managing-gdu-agent-ecs-automated.md)
+ [自动管理 Amazon EKS 资源的安全代理](managing-gdu-agent-eks-automatically.md)
+ [手动管理 Amazon EKS 集群的安全代理](managing-gdu-agent-eks-manually.md)
+ [为 Amazon EKS 配置 GuardDuty 安全代理（附加组件）参数](guardduty-configure-security-agent-eks-addon.md)
+ [验证 VPC 端点配置](validate-vpc-endpoint-config-runtime-monitoring.md)

# 为 Amazon EC2 实例启用自动安全代理
<a name="managing-gdu-agent-ec2-automated"></a>

本节包括在您的独立账户或多账户环境中为您的 Amazon EC2 资源启用 GuardDuty 自动代理的步骤。

在继续操作之前，请确保您已满足所有 [Amazon EC2 实例支持的先决条件](prereq-runtime-monitoring-ec2-support.md)。

如果您要从手动管理 GuardDuty 代理迁移到启用 GuardDuty 自动代理，则在按照步骤启用 GuardDuty 自动代理之前，请参阅[从 Amazon EC2 手动代理迁移到自动代理](migrate-from-ec2-manual-to-automated-agent.md)。

# 在多账户环境中为 Amazon EC2 资源启用 GuardDuty 代理
<a name="manage-agent-ec2-multi-account-env"></a>

在多账户环境中，只有委派的 GuardDuty 管理员帐户才能为属于其组织中成员账户的资源类型启用或禁用自动代理配置。 GuardDuty 成员账户无法通过其账户修改此配置。委托 GuardDuty 管理员账户账户使用管理其成员账户 AWS Organizations。有关多账户环境的更多信息，请参阅[管理多个账户](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_accounts.html)。

## 适用于委派 GuardDuty 管理员账号
<a name="configure-for-delegated-admin"></a>

------
#### [ Configure for all instances ]

如果您选择 “**为所有帐户启用**运行时监控”，则为委派的 GuardDuty 管理员帐户选择以下选项之一：
+ **选项 1**

  在**自动代理配置**下的 **EC2** 部分中，选择**为所有账户启用**。
+ **选项 2**
  + 在**自动代理配置**下的 **EC2** 部分中，选择**手动配置账户**。
  + 在**委派管理员（此账户）**下选择**启用**。
+ 选择**保存**。

如果您为运行时监控选择了**手动配置账户**，请执行以下步骤：
+ 在**自动代理配置**下的 **EC2** 部分中，选择**手动配置账户**。
+ 在**委派管理员（此账户）**下选择**启用**。
+ 选择**保存**。

无论您选择哪个选项为委派 GuardDuty 管理员账户启用自动代理配置，您都可以验证 GuardDuty 创建的 SSM 关联是否将在属于该账户的所有 EC2 资源上安装和管理安全代理。

1. 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

1. 打开该 SSM 关联 (`GuardDutyRuntimeMonitoring-do-not-delete`) 的**目标**选项卡。请注意，T **ag 键**显示为**InstanceIds**。

------
#### [ Using inclusion tag in selected instances ]

**为选定的 Amazon EC2 实例配置 GuardDuty 代理**

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

1. 将`GuardDutyManaged`:`true`标签添加到 GuardDuty 要监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

   添加此标签将允许 GuardDuty 为这些选定的 EC2 实例安装和管理安全代理。您**无需**显式启用自动代理配置。

1. 您可以验证 GuardDuty 创建的 SSM 关联是否仅在标有包含标签的 EC2 资源上安装和管理安全代理。

   打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

   1. 打开所创建的 SSM 关联 (`GuardDutyRuntimeMonitoring-do-not-delete`) 的**目标**选项卡。**标签键**显示为**标签:GuardDutyManaged**。

------
#### [ Using exclusion tag in selected instances ]

**注意**  
务必要在启动 Amazon EC2 实例之前添加排除标签。为 Amazon EC2 启用自动代理配置后，任何启动时没有排除标签的 EC2 实例都将受到 GuardDuty 自动代理配置的保护。

**为选定的 Amazon EC2 实例配置 GuardDuty 代理**

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

1. 将`GuardDutyManaged`:`false`标签添加到您**不** GuardDuty 想监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

1. 

**要使[排除标签在实例元数据中可用](https://docs.aws.amazon.com/guardduty/latest/ug/prereq-runtime-monitoring-ec2-support.html#general-runtime-monitoring-prereq-ec2)，请执行以下步骤：**

   1. 在实例的**详细信息**选项卡下，查看**允许在实例元数据中使用标签**的状态。

      如果当前为**已禁用**，请按照以下步骤将其状态更改为**已启用**。否则，请跳过此步骤。

   1. 在**操作**菜单下，选择**实例设置**。

   1. 选择**允许在实例元数据中使用标签**。

1. 添加排除标签后，执行与**为所有实例配置**选项卡中指定的相同步骤。

------

现在，您可以评估运行时[Amazon EC2 实例的运行时覆盖率和故障排除](gdu-assess-coverage-ec2.md)。

## 为所有成员账户自动启用
<a name="auto-enable-all-member-accounts"></a>

**注意**  
更新成员账户的配置可能最长需要 24 小时。

------
#### [ Configure for all instances ]

以下步骤假设您在“运行时监控”部分选择了**为所有账户启用**：

1. 在 **Amazon EC2** 的**自动代理配置**部分中，选择**为所有账户启用**。

1. 您可以验证 GuardDuty 创建 (`GuardDutyRuntimeMonitoring-do-not-delete`) 的 SSM 关联是否将在属于该账户的所有 EC2 资源上安装和管理安全代理。

   1. 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

   1. 打开该 SSM 关联的**目标**选项卡。请注意，T **ag 键**显示为**InstanceIds**。

------
#### [ Using inclusion tag in selected instances ]

**为选定的 Amazon EC2 实例配置 GuardDuty 代理**

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

1. 将`GuardDutyManaged`:`true`标签添加到 GuardDuty 要监控和检测潜在威胁的 EC2 实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

   添加此标签将允许 GuardDuty 为这些选定的 EC2 实例安装和管理安全代理。您**无需**显式启用自动代理配置。

1. 您可以验证 GuardDuty 创建的 SSM 关联是否会在属于您账户的所有 EC2 资源上安装和管理安全代理。

   1. 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

   1. 打开该 SSM 关联 (`GuardDutyRuntimeMonitoring-do-not-delete`) 的**目标**选项卡。请注意，T **ag 键**显示为**InstanceIds**。

------
#### [ Using exclusion tag in selected instances ]

**注意**  
务必要在启动 Amazon EC2 实例之前添加排除标签。为 Amazon EC2 启用自动代理配置后，任何启动时没有排除标签的 EC2 实例都将受到 GuardDuty 自动代理配置的保护。

**为选定的 Amazon EC2 实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`false`标签添加到您**不** GuardDuty 想监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

1. 

**要使[排除标签在实例元数据中可用](https://docs.aws.amazon.com/guardduty/latest/ug/prereq-runtime-monitoring-ec2-support.html#general-runtime-monitoring-prereq-ec2)，请执行以下步骤：**

   1. 在实例的**详细信息**选项卡下，查看**允许在实例元数据中使用标签**的状态。

      如果当前为**已禁用**，请按照以下步骤将其状态更改为**已启用**。否则，请跳过此步骤。

   1. 在**操作**菜单下，选择**实例设置**。

   1. 选择**允许在实例元数据中使用标签**。

1. 添加排除标签后，执行与**为所有实例配置**选项卡中指定的相同步骤。

------

现在，您可以评估运行时[Amazon EC2 实例的运行时覆盖率和故障排除](gdu-assess-coverage-ec2.md)。

## 仅为新成员账户自动启用
<a name="auto-enable-new-member-accounts"></a>

委托 GuardDuty 管理员账户可以将 Amazon EC2 资源的自动代理配置设置为在新成员账户加入组织时自动启用。

------
#### [ Configure for all instances ]

以下步骤假设您在**运行时监控**部分下选择了**为新成员账户自动启用**：

1. 在导航窗格中，选择**运行时监控**。

1. 在**运行时监控**页面上，选择**编辑**。

1. 选择**为新成员账户自动启用**。此步骤可确保每当有新账户加入您的组织时，系统都会自动为其账户启用 Amazon EC2 自动代理配置。只有组织的委派 GuardDuty 管理员帐户可以修改此选择。

1. 选择**保存**。

当新成员账户加入组织时，系统将自动为其启用此配置。 GuardDuty 要管理属于此新成员账户的 Amazon EC2 实例的安全代理，请确保满足[对于 EC2 实例](prereq-runtime-monitoring-ec2-support.md)所有先决条件。

创建 SSM 关联 (`GuardDutyRuntimeMonitoring-do-not-delete`) 后，您可以验证 SSM 关联是否将在属于该新成员账户的所有 EC2 实例上安装和管理安全代理。
+ 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。
+ 打开该 SSM 关联的**目标**选项卡。请注意，T **ag 键**显示为**InstanceIds**。

------
#### [ Using inclusion tag in selected instances ]

**为账户中的选定实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`true`标签添加到 GuardDuty 要监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

   添加此标签将 GuardDuty 允许为这些选定实例安装和管理安全代理。您无需显式启用自动代理配置。

1. 您可以验证 GuardDuty 创建的 SSM 关联是否仅在标有包含标签的 EC2 资源上安装和管理安全代理。

   1. 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

   1. 打开所创建的 SSM 关联的**目标**选项卡。**标签键**显示为**标签:GuardDutyManaged**。

------
#### [ Using exclusion tag in selected instances ]

**注意**  
务必要在启动 Amazon EC2 实例之前添加排除标签。为 Amazon EC2 启用自动代理配置后，任何启动时没有排除标签的 EC2 实例都将受到 GuardDuty 自动代理配置的保护。

**为独立账户中的特定实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`false`标签添加到您**不** GuardDuty 想监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

1. 

**要使[排除标签在实例元数据中可用](https://docs.aws.amazon.com/guardduty/latest/ug/prereq-runtime-monitoring-ec2-support.html#general-runtime-monitoring-prereq-ec2)，请执行以下步骤：**

   1. 在实例的**详细信息**选项卡下，查看**允许在实例元数据中使用标签**的状态。

      如果当前为**已禁用**，请按照以下步骤将其状态更改为**已启用**。否则，请跳过此步骤。

   1. 在**操作**菜单下，选择**实例设置**。

   1. 选择**允许在实例元数据中使用标签**。

1. 添加排除标签后，执行与**为所有实例配置**选项卡中指定的相同步骤。

------

现在，您可以评估运行时[Amazon EC2 实例的运行时覆盖率和故障排除](gdu-assess-coverage-ec2.md)。

## 仅限选定成员账户
<a name="enable-selective-member-accounts-only"></a>

------
#### [ Configure for all instances ]

1. 在**账户**页面上，选择要为其启用**运行时监控 – 自动代理配置（Amazon EC2）**的一个或多个账户。确保您在此步骤中选择的账户已启用运行时监控。

1. 从**编辑防护计划**中选择相应的选项，以启用**运行时监控 – 自动代理配置（Amazon EC2）**。

1. 选择**确认**。

------
#### [ Using inclusion tag in selected instances ]

**为选定实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`true`标签添加到 GuardDuty 要监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

   添加此标签将 GuardDuty 允许您管理已标记的 Amazon EC2 实例的安全代理。您无需显式启用自动代理配置 [**运行时监控 – 自动代理配置（EC2）**]。

------
#### [ Using exclusion tag in selected instances ]

**注意**  
务必要在启动 Amazon EC2 实例之前添加排除标签。为 Amazon EC2 启用自动代理配置后，任何启动时没有排除标签的 EC2 实例都将受到 GuardDuty 自动代理配置的保护。

**为选定实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`false`标签添加到您**不** GuardDuty 想监控或检测潜在威胁的 EC2 实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

1. 

**要使[排除标签在实例元数据中可用](https://docs.aws.amazon.com/guardduty/latest/ug/prereq-runtime-monitoring-ec2-support.html#general-runtime-monitoring-prereq-ec2)，请执行以下步骤：**

   1. 在实例的**详细信息**选项卡下，查看**允许在实例元数据中使用标签**的状态。

      如果当前为**已禁用**，请按照以下步骤将其状态更改为**已启用**。否则，请跳过此步骤。

   1. 在**操作**菜单下，选择**实例设置**。

   1. 选择**允许在实例元数据中使用标签**。

1. 添加排除标签后，执行与**为所有实例配置**选项卡中指定的相同步骤。

------

您现在可以评估[Amazon EC2 实例的运行时覆盖率和故障排除](gdu-assess-coverage-ec2.md)。

# 为独立账户中的 Amazon EC2 资源启用 GuardDuty 自动代理
<a name="manage-agent-ec2-standalone-account"></a>

独立账户拥有在特定账户中启用或禁用保护计划的决定 AWS 区域。 AWS 账户 

如果您的账户通过或通过 AWS Organizations邀请方式与 GuardDuty 管理员帐户关联，则此部分不适用于您的账户。有关更多信息，请参阅 [为多账户环境启用运行时监控](enable-runtime-monitoring-multiple-acc-env.md)。

启用运行时监控后，请确保通过自动配置或手动部署来安装 GuardDuty 安全代理。在完成以下过程中列出的所有步骤时，务必要安装安全代理。

根据您是要监控全部还是部分 Amazon EC2 资源的偏好，选择一种您偏好的方法并按照下表中的步骤进行操作。

------
#### [ Configure for all instances ]

**为独立账户中的所有实例配置运行时监控**

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

1. 在导航窗格中，选择**运行时监控**。

1. 在**配置**选项卡下，选择**编辑**。

1. 在 **EC2** 部分中，选择**启用**。

1. 选择**保存**。

1. 您可以验证 GuardDuty 创建的 SSM 关联是否会在属于您账户的所有 EC2 资源上安装和管理安全代理。

   1. 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

   1. 打开该 SSM 关联 (`GuardDutyRuntimeMonitoring-do-not-delete`) 的**目标**选项卡。请注意，T **ag 键**显示为**InstanceIds**。

------
#### [ Using inclusion tag in selected instances ]

**为选定的 Amazon EC2 实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`true`标签添加到 GuardDuty 要监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

1. 您可以验证 GuardDuty 创建的 SSM 关联是否仅在标有包含标签的 EC2 资源上安装和管理安全代理。

   打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

   1. 打开所创建的 SSM 关联 (`GuardDutyRuntimeMonitoring-do-not-delete`) 的**目标**选项卡。**标签键**显示为**标签:GuardDutyManaged**。

------
#### [ Using exclusion tag in selected instances ]

**注意**  
务必要在启动 Amazon EC2 实例之前添加排除标签。为 Amazon EC2 启用自动代理配置后，任何启动时没有排除标签的 EC2 实例都将受到 GuardDuty 自动代理配置的保护。

**为选定的 Amazon EC2 实例配置 GuardDuty 安全代理**

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

1. 将`GuardDutyManaged`:`false`标签添加到您**不** GuardDuty 想监控和检测潜在威胁的实例。有关添加此标签的信息，请参阅[为单个资源添加标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)。

1. 

**要使[排除标签在实例元数据中可用](https://docs.aws.amazon.com/guardduty/latest/ug/prereq-runtime-monitoring-ec2-support.html#general-runtime-monitoring-prereq-ec2)，请执行以下步骤：**

   1. 在实例的**详细信息**选项卡下，查看**允许在实例元数据中使用标签**的状态。

      如果当前为**已禁用**，请按照以下步骤将其状态更改为**已启用**。否则，请跳过此步骤。

   1. 选择您想允许其使用标签的实例。

   1. 在**操作**菜单下，选择**实例设置**。

   1. 选择**允许在实例元数据中使用标签**。

   1. 在**访问实例元数据中的标签**下，选择**允许**。

   1. 选择**保存**。

1. 添加排除标签后，执行与**为所有实例配置**选项卡中指定的相同步骤。

------

现在，您可以评估运行时[Amazon EC2 实例的运行时覆盖率和故障排除](gdu-assess-coverage-ec2.md)。

# 从 Amazon EC2 手动代理迁移到自动代理
<a name="migrate-from-ec2-manual-to-automated-agent"></a>

 AWS 账户 如果您以前手动管理安全客户端，现在想要使用 GuardDuty 自动代理配置，则本节适用于您。如果本节的内容不适用于您，请继续为您的账户配置安全代理。

启用 GuardDuty 自动代理后，将代表您 GuardDuty 管理安全客户端。有关 GuardDuty 采取了哪些步骤的信息，请参阅[使用自动代理配置（推荐）](how-runtime-monitoring-works-ec2.md#use-automated-agent-config-ec2)。

## 清理 资源
<a name="ec2-clean-up-migrate-from-manual-to-automated"></a>

**删除 SSM 关联**  
+ 删除您在手动管理 Amazon EC2 安全代理时可能创建的任何 SSM 关联。有关更多信息，请参阅[删除关联](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-state-manager-delete-association.html)。
+ 这样做是为了让无论您是在账户级别还是实例级别使用自动代理（通过使用包含或排除标签）， GuardDuty 都可以接管 SSM 操作的管理。有关 SSM 可以执行的操作的更多信息 GuardDuty ，请参阅[的服务相关角色权限 GuardDuty](slr-permissions.md)。
+ 删除先前为手动管理安全代理而创建的 SSM 关联时，在创建用于自动管理安全代理的 SSM 关联时 GuardDuty 可能会有短暂的重叠期。在此期间，您可能会遇到源自 SSM 调度的冲突。有关更多信息，请参阅 [Amazon EC2 SSM 调度](https://docs.aws.amazon.com/systems-manager/latest/userguide/quick-setup-scheduler.html)。

**管理 Amazon EC2 实例的包含标签和排除标签**  
+ **包含标签** — 如果您不启用 GuardDuty自动代理配置，但使用包含标签 (`GuardDutyManaged`:`true`) 标记任何 Amazon EC2 实例，则会 GuardDuty 创建 SSM 关联，该关联将在选定的 EC2 实例上安装和管理安全代理。这是一种预期的行为，有助您仅管理选定 EC2 实例上的安全代理。有关更多信息，请参阅 [运行时监控如何与 Amazon EC2 实例结合使用](how-runtime-monitoring-works-ec2.md)。

  要防止 GuardDuty 安装和管理安全代理，请从这些 EC2 实例中移除包含标签。有关更多信息，请参阅《Amazon EC2 用户指南》中的[添加和删除标签](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#adding-or-deleting-tags)**。
+ **排除标签** — 当您想要为账户中的所有 EC2 实例启用 GuardDuty自动代理配置时，请确保没有一个 EC2 实例被标记为排除标签 (`GuardDutyManaged`:`false`)。

# 手动管理 Amazon EC2 资源的安全代理
<a name="managing-gdu-agent-ec2-manually"></a>

本节介绍了手动安装和更新 Amazon EC2 资源安全代理的步骤。

启用运行时监控后，您需要手动安装 GuardDuty 安全代理。要手动管理 GuardDuty 安全代理，必须先手动创建 Amazon VPC 终端节点。之后，您可以安装安全代理，这样它 GuardDuty 就可以开始接收来自 Amazon EC2 实例的运行时事件。 GuardDuty 发布此资源的新代理版本时，您可以更新账户中的代理版本。

以下主题包含了持续管理 Amazon EC2 资源的安全代理的步骤。

**Topics**
+ [先决条件 – 手动创建 Amazon VPC 端点](creating-vpc-endpoint-ec2-agent-manually.md)
+ [手动安装安全代理](installing-gdu-security-agent-ec2-manually.md)
+ [手动更新 Amazon EC2 实例 GuardDuty 的安全代理](gdu-update-security-agent-ec2.md)

# 先决条件 – 手动创建 Amazon VPC 端点
<a name="creating-vpc-endpoint-ec2-agent-manually"></a>

在安装 GuardDuty 安全代理之前，必须先创建亚马逊虚拟私有云 (Amazon VPC) 终端节点。这将有助于 GuardDuty 接收您的 Amazon EC2 实例的运行时事件。

**注意**  
使用 VPC 端点不会产生额外的成本。

**创建 Amazon VPC 端点**

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

1. 在导航窗格中的 **VPC 私有云**下，选择**端点**。

1. 选择**创建端点**。

1. 在**创建端点**页面​​上，对于**服务类别**，选择**其他端点服务**。

1. 对于**服务名称**，输入 **com.amazonaws.*us-east-1*.guardduty-data**。

   请务必*us-east-1*用您的 AWS 区域。该区域必须与属于您的 AWS 账户 ID 的 Amazon EC2 实例位于同一区域。

1. 选择**验证服务**。

1. 成功验证服务名称后，选择实例所在的 **VPC**。添加以下策略，以仅允许指定账户使用该 Amazon VPC 端点。使用此策略下面提供的组织 `Condition`，您可以更新以下策略来限制对端点的访问。要向您组织 IDs 中的特定账户提供 Amazon VPC 终端节点支持，请参阅[Organization condition to restrict access to your endpoint](#gdu-runtime-ec2-organization-restrict-access-vpc-endpoint)。

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

****  

   ```
   {
   	"Version":"2012-10-17",		 	 	 
   	"Statement": [
   		{
   			"Action": "*",
   			"Resource": "*",
   			"Effect": "Allow",
   			"Principal": "*"
   		},
   		{
   			"Condition": {
   				"StringNotEquals": {
   					"aws:PrincipalAccount": "111122223333" 
   				}
   			},
   			"Action": "*",
   			"Resource": "*",
   			"Effect": "Deny",
   			"Principal": "*"
   		}
   	]
   }
   ```

------

   `aws:PrincipalAccount` 账户 ID 必须与包含 VPC 和 VPC 端点的账户匹配。以下列表显示如何与其他 AWS 账户共享 VPC 终端节点 IDs：<a name="gdu-runtime-ec2-organization-restrict-access-vpc-endpoint"></a>
   + 要指定多个账户访问该 VPC 端点的权限，请将 `"aws:PrincipalAccount: "111122223333"` 替换为以下代码块：

     ```
     "aws:PrincipalAccount": [
               "666666666666",
               "555555555555"
           ]
     ```

     请务必将该 AWS 账户 IDs 替换为需要访问 VPC 终端节点的账户的账户。 IDs 
   + 要允许组织中的所有成员访问 VPC 端点，请将 `"aws:PrincipalAccount: "111122223333"` 替换为以下行：

     ```
     "aws:PrincipalOrgID": "o-abcdef0123"
     ```

     请务必*o-abcdef0123*用您的组织 ID 替换组织。
   + 要按组织 ID 限制资源访问权限，请将您的 `ResourceOrgID` 添加到策略中。有关更多信息，请参阅《IAM 用户指南》**中的 [https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceorgid](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceorgid)。

     ```
     "aws:ResourceOrgID": "o-abcdef0123"
     ```

1. 在**其他设置**下，选择**启用 DNS 名称**。

1. 在**子网**下，选择实例所在的子网。

1. 在**安全组**下，选择从 VPC（或 Amazon EC2 实例）启用了入站端口 443 的安全组。如果您还没有启用了入站端口 443 的安全组，请参阅《Amazon VPC 用户指南》中的[创建为 VPC 创建安全组](https://docs.aws.amazon.com/vpc/latest/userguide/creating-security-groups.html)**。

   如果将入站权限限定为您的 VPC（或实例）时出现问题，您可以从任何 IP 地址 `(0.0.0.0/0)` 提供入站 443 端口支持。但是， GuardDuty 建议使用与您的 VPC 的 CIDR 块相匹配的 IP 地址。有关更多信息，请参阅《Amazon VPC 用户指南》中的 [VPC CIDR 块](https://docs.aws.amazon.com//vpc/latest/userguide/vpc-cidr-blocks.html)**。

完成这些步骤后，请参阅[验证 VPC 端点配置](validate-vpc-endpoint-config-runtime-monitoring.md)以确保 VPC 端点的设置正确。

# 手动安装安全代理
<a name="installing-gdu-security-agent-ec2-manually"></a>

GuardDuty 提供了以下两种在您的 Amazon EC2 实例上安装 GuardDuty 安全代理的方法。在继续操作之前，请务必完成[先决条件 – 手动创建 Amazon VPC 端点](creating-vpc-endpoint-ec2-agent-manually.md)下的步骤。

选择一种您偏好的访问方法，在您的 Amazon EC2 资源中安装安全代理。
+ [方法 1-使用 AWS Systems Manager](#install-gdu-by-using-sys-runtime-monitoring)— 此方法需要 AWS Systems Manager 管理您的 Amazon EC2 实例。
+ [方法 2 – 使用 Linux 软件包管理器](#install-gdu-by-rpm-scripts-runtime-monitoring)— 无论您的 Amazon EC2 实例是否处于 AWS Systems Manager 托管状态，您都可以使用此方法。根据您的[操作系统发行版](https://docs.aws.amazon.com/guardduty/latest/ug/prereq-runtime-monitoring-ec2-support.html#validating-architecture-req-ec2)，您可以选择合适的方法来安装 RPM 脚本或 Debian 脚本。如果您使用 *Fedora* 平台，则必须使用此方法来安装代理。

## 方法 1-使用 AWS Systems Manager
<a name="install-gdu-by-using-sys-runtime-monitoring"></a>

要使用此方法，请确保您的 Amazon EC2 实例处于 AWS Systems Manager 托管状态，然后安装代理。

### AWS Systems Manager 托管 Amazon EC2 实例
<a name="manage-ssm-ec2-instance-runtime-monitoring"></a>

按照以下步骤操作，以确保您的 Amazon EC2 实例由 AWS Systems Manager 托管。
+ [AWS Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html)帮助您管理 AWS 应用程序和资源 end-to-end并实现大规模的安全运营。

  要使用管理您的 Amazon EC2 实例 AWS Systems Manager，请参阅*AWS Systems Manager 用户指南*中的为 [Amazon EC2 实例设置 Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-setting-up-ec2.html)。
+ 下表显示了新的 GuardDuty 托管 AWS Systems Manager 文档：    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/installing-gdu-security-agent-ec2-manually.html)

  有关更多信息 AWS Systems Manager，请参阅《*AWS Systems Manager 用户指南》*[中的 Amazon EC2 Systems Manager 文档](https://docs.aws.amazon.com/systems-manager/latest/userguide/documents.html)。
**对于 Debian Server**  
提供的适用于 Debian 服务器的 Amazon 机器映像 (AMIs) AWS 要求您安装 AWS Systems Manager 代理（SSM 代理）。您需要执行额外的步骤来安装 SSM Agent，以确保 Amazon EC2 Debian 服务器实例由 SSM 托管。有关您需要执行的步骤的信息，请参阅《AWS Systems Manager 用户指南》中的[在 Debian Server 实例上手动安装 SSM Agent](https://docs.aws.amazon.com/systems-manager/latest/userguide/agent-install-deb.html)**。

**要安装适用于 Amazon EC2 实例的 GuardDuty 代理，请使用以下方法 AWS Systems Manager**

1. 打开 AWS Systems Manager 控制台，网址为[https://console.aws.amazon.com/systems-manager/](https://console.aws.amazon.com/systems-manager/)。

1. 在导航窗格中，选择**文档**

1. 在**由 Amazon 所有**中，选择 `AmazonGuardDuty-ConfigureRuntimeMonitoringSsmPlugin`。

1. 选择 **Run Command**。

1. 输入以下 Run 命令参数
   + 操作：选择**安装**。
   + 安装类型：选择**安装或卸载**。
   + 名称: `AmazonGuardDuty-RuntimeMonitoringSsmPlugin`
   + 版本：如果此处仍为空，您将获得最新版本 GuardDuty 的安全客户端。有关发行版本的更多信息，请参阅[GuardDuty Amazon EC2 实例的安全代理版本](runtime-monitoring-agent-release-history.md#ec2-gdu-agent-release-history)。

1. 选择目标 Amazon EC2 实例。您可以选择一个或多个 Amazon EC2 实例。有关更多信息，请参阅《AWS Systems Manager 用户指南》中的[从控制台运行AWS Systems Manager 命令](https://docs.aws.amazon.com/systems-manager/latest/userguide/running-commands-console.html)**。

1. 验证 GuardDuty 代理安装是否正常。有关更多信息，请参阅 [正在验证 GuardDuty 安全代理安装状态](#validate-ec2-gdu-agent-installation-healthy)。

## 方法 2 – 使用 Linux 软件包管理器
<a name="install-gdu-by-rpm-scripts-runtime-monitoring"></a>

使用此方法，您可以通过运行 RPM 脚本或 Debian 脚本来安装 GuardDuty 安全代理。您可以根据操作系统来选择一种偏好的方法：
+ 使用 RPM 脚本在操作系统发行版 AL2、、 AL2023 RedHat、CentOS 或 Fedora 上安装安全代理。
+ 使用 Debian 脚本在 Ubuntu 或 Debian 操作系统发行版上安装安全代理。有关支持的 Ubuntu 和 Debian 操作系统发行版的信息，请参阅 [验证架构要求](prereq-runtime-monitoring-ec2-support.md#validating-architecture-req-ec2)。

------
#### [ RPM installation ]
**重要**  
我们建议先验证 GuardDuty 安全代理 RPM 签名，然后再将其安装到您的计算机上。

1. 验证 GuardDuty 安全代理 RPM 签名

   1. 

**准备模板**

      使用适当的公有密钥、x86\$164 RPM 签名、arm64 RPM 签名以及指向 Amazon S3 存储桶中所托管 RPM 脚本的相应访问链接来准备命令。替换 AWS 区域、 AWS 账户 ID 和 GuardDuty 代理版本的值以访问 RPM 脚本。
      + **公有密钥**：

        ```
        s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/publickey.pem
        ```
      + **GuardDuty 安全代理 RPM 签名**：  
x86\$164 RPM 签名  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/x86_64/amazon-guardduty-agent-1.9.2.x86_64.sig
        ```  
arm64 RPM 签名  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/arm64/amazon-guardduty-agent-1.9.2.arm64.sig
        ```
      + **Amazon S3 存储桶中 RPM 脚本的访问链接**：  
x86\$164 RPM 访问链接  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/x86_64/amazon-guardduty-agent-1.9.2.x86_64.rpm
        ```  
arm64 RPM 访问链接  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/arm64/amazon-guardduty-agent-1.9.2.arm64.rpm
        ```    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/installing-gdu-security-agent-ec2-manually.html)

   1. 

**下载模板**

      以下命令用于下载相应的公有密钥、x86\$164 RPM 签名、arm64 RPM 签名以及指向 Amazon S3 存储桶中所托管 RPM 脚本的相应访问链接，务必要将账户 ID 替换为相应 AWS 账户 ID，将区域替换为您当前所在的区域。

      ```
      aws s3 cp s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/x86_64/amazon-guardduty-agent-1.9.2.x86_64.rpm ./amazon-guardduty-agent-1.9.2.x86_64.rpm
      aws s3 cp s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/x86_64/amazon-guardduty-agent-1.9.2.x86_64.sig ./amazon-guardduty-agent-1.9.2.x86_64.sig
      aws s3 cp s3://694911143906-eu-west-1-guardduty-agent-rpm-artifacts/1.9.2/publickey.pem ./publickey.pem
      ```

   1. 

**导入公有密钥**

      使用以下命令将公有密钥导入到数据库：

      ```
      gpg --import publickey.pem
      ```

      gpg 显示导入成功

      ```
      gpg: key 093FF49D: public key "AwsGuardDuty" imported
      gpg: Total number processed: 1
      gpg:               imported: 1  (RSA: 1)
      ```

   1. 

**验证签名**

      使用以下命令验证签名

      ```
      gpg --verify amazon-guardduty-agent-1.9.2.x86_64.sig amazon-guardduty-agent-1.9.2.x86_64.rpm
      ```

      如果通过验证，您将看到类似于以下结果的消息。现在，您可以继续使用 RPM 安装 GuardDuty 安全代理。

      输出示例：

      ```
      gpg: Signature made Fri 17 Nov 2023 07:58:11 PM UTC using ? key ID 093FF49D
      gpg: Good signature from "AwsGuardDuty"
      gpg: WARNING: This key is not certified with a trusted signature!
      gpg:          There is no indication that the signature belongs to the owner.
      Primary key fingerprint: 7478 91EF 5378 1334 4456  7603 06C9 06A7 093F F49D
      ```

      如果验证失败，则意味着 RPM 上的签名可能已被篡改。您必须从数据库中移除该公有密钥并重试验证过程。

      示例：

      ```
      gpg: Signature made Fri 17 Nov 2023 07:58:11 PM UTC using ? key ID 093FF49D
      gpg: BAD signature from "AwsGuardDuty"
      ```

      使用以下命令从数据库中移除公有密钥：

      ```
      gpg --delete-keys AwsGuardDuty
      ```

      现在，再次尝试验证过程。

1. [从 Linux 或 macOS 使用 SSH 连接](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-linux-inst-ssh.html)。

1. 使用以下命令安装 GuardDuty 安全代理：

   ```
   sudo rpm -ivh amazon-guardduty-agent-1.9.2.x86_64.rpm
   ```

1. 验证 GuardDuty 代理安装是否正常。有关这些步骤的更多信息，请参阅[正在验证 GuardDuty 安全代理安装状态](#validate-ec2-gdu-agent-installation-healthy)。

------
#### [ Debian installation ]
**重要**  
我们建议先验证 GuardDuty 安全代理 Debian 签名，然后再将其安装到您的计算机上。

1. 验证 GuardDuty 安全代理 Debian 签名

   1. 

**为相应的公有密钥、amd64 Debian 软件包签名、arm64 Debian 软件包签名以及 Amazon S3 存储桶中所托管 Debian 脚本的相应访问链接准备模板**

      在以下模板中，替换 AWS 账户 ID 和 GuardDuty代理版本的值以访问 Debian 软件包脚本。 AWS 区域
      + **公有密钥**：

        ```
        s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/publickey.pem
        ```
      + **GuardDuty 安全代理 Debian 签名**：  
amd64 签名  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/amd64/amazon-guardduty-agent-1.9.2.amd64.sig
        ```  
arm64 签名  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/arm64/amazon-guardduty-agent-1.9.2.arm64.sig
        ```
      + **Amazon S3 存储桶中 Debian 脚本的访问链接**：  
amd64 访问链接  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/amd64/amazon-guardduty-agent-1.9.2.amd64.deb
        ```  
arm64 访问链接  

        ```
        s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/arm64/amazon-guardduty-agent-1.9.2.arm64.deb
        ```    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/installing-gdu-security-agent-ec2-manually.html)

   1. 

**下载相应的公有密钥、amd64 签名、arm64 签名以及 Amazon S3 存储桶中所托管 Debian 脚本的相应访问链接**

      在以下命令中，将账户 ID 替换为相应的 AWS 账户 ID，将地区替换为您当前的区域。

      ```
      aws s3 cp s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/amd64/amazon-guardduty-agent-1.9.2.amd64.deb ./amazon-guardduty-agent-1.9.2.amd64.deb
      aws s3 cp s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/amd64/amazon-guardduty-agent-1.9.2.amd64.sig ./amazon-guardduty-agent-1.9.2.amd64.sig
      aws s3 cp s3://694911143906-eu-west-1-guardduty-agent-deb-artifacts/1.9.2/publickey.pem ./publickey.pem
      ```

   1. 将公有密钥导入数据库中

      ```
      gpg --import publickey.pem
      ```

      gpg 显示导入成功

      ```
      gpg: key 093FF49D: public key "AwsGuardDuty" imported
      gpg: Total number processed: 1
      gpg:               imported: 1  (RSA: 1)
      ```

   1. 验证签名

      ```
      gpg --verify amazon-guardduty-agent-1.9.2.amd64.sig amazon-guardduty-agent-1.9.2.amd64.deb
      ```

      如果验证成功，您将看到与以下结果类似的消息：

      输出示例：

      ```
      gpg: Signature made Fri 17 Nov 2023 07:58:11 PM UTC using ? key ID 093FF49D
      gpg: Good signature from "AwsGuardDuty"
      gpg: WARNING: This key is not certified with a trusted signature!
      gpg:          There is no indication that the signature belongs to the owner.
      Primary key fingerprint: 7478 91EF 5378 1334 4456  7603 06C9 06A7 093F F49D
      ```

      现在，您可以继续使用 Debian 安装 GuardDuty 安全代理。

      但如果验证失败，则意味着 Debian 软件包中的签名可能已被篡改。

      示例：

      ```
      gpg: Signature made Fri 17 Nov 2023 07:58:11 PM UTC using ? key ID 093FF49D
      gpg: BAD signature from "AwsGuardDuty"
      ```

      使用以下命令从数据库中移除公有密钥：

      ```
      gpg --delete-keys AwsGuardDuty
      ```

      现在，重新尝试验证过程。

1. [从 Linux 或 macOS 使用 SSH 连接](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-linux-inst-ssh.html)。

1. 使用以下命令安装 GuardDuty 安全代理：

   ```
   sudo dpkg -i amazon-guardduty-agent-1.9.2.amd64.deb
   ```

1. 验证 GuardDuty 代理安装是否正常。有关这些步骤的更多信息，请参阅[正在验证 GuardDuty 安全代理安装状态](#validate-ec2-gdu-agent-installation-healthy)。

------

## 内存不足错误
<a name="out-of-memory-error-ec2-instal-agent-manual"></a>

如果您在手动安装或更新 Amazon EC2 GuardDuty 的安全代理时`out-of-memory`遇到错误，请参阅[内存不足问题的故障排除](troubleshooting-guardduty-runtime-monitoring.md#troubleshoot-ec2-cpu-out-of-memory-error)。

## 正在验证 GuardDuty 安全代理安装状态
<a name="validate-ec2-gdu-agent-installation-healthy"></a>

执行安装 GuardDuty 安全代理的步骤后，请使用以下步骤验证代理的状态：

**验证 GuardDuty 安全代理是否正常**

1. [从 Linux 或 macOS 使用 SSH 连接](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-linux-inst-ssh.html)。

1. 运行以下命令以检查 GuardDuty 安全代理的状态：

   ```
   sudo systemctl status amazon-guardduty-agent
   ```

要查看安全代理安装日志，可通过路径 `/var/log/amzn-guardduty-agent/` 获取。

要查看日志，请运行 `sudo journalctl -u amazon-guardduty-agent`。

# 手动更新 Amazon EC2 实例 GuardDuty 的安全代理
<a name="gdu-update-security-agent-ec2"></a>

GuardDuty 发布安全代理版本的更新。如果您手动管理安全代理，您自行负责为 Amazon EC2 实例更新代理。有关新代理版本的信息，请参阅适用于 Amazon EC2 实例的 [GuardDuty 安全代理发布版本](runtime-monitoring-agent-release-history.md)。要接收有关新代理版本发布的通知，请参阅[订阅 Amazon SNS 公告 GuardDuty](guardduty_sns.md)。

**手动为 Amazon EC2 实例更新安全代理**  
更新安全代理的过程与安装安全代理的过程相同。根据您安装代理所用的方法，您可以执行为 Amazon EC2 实例[手动安装安全代理](installing-gdu-security-agent-ec2-manually.md)中的步骤。  
如果您使用[方法 1-使用 AWS Systems Manager](https://docs.aws.amazon.com/guardduty/latest/ug/managing-gdu-agent-ec2-manually.html#manage-ssm-ec2-instance-runtime-monitoring)，则可以使用 **Run 命令**更新安全代理。使用要更新的代理版本。  
如果您使用[方法 2 – 使用 Linux 软件包管理器](https://docs.aws.amazon.com/guardduty/latest/ug/managing-gdu-agent-ec2-manually.html#heading:r2l:)，则可以使用[手动安装安全代理](installing-gdu-security-agent-ec2-manually.md)部分中指定的脚本。这些脚本已经包含最新的代理发行版本。有关最新发行的代理版本的信息，请参阅[GuardDuty Amazon EC2 实例的安全代理版本](runtime-monitoring-agent-release-history.md#ec2-gdu-agent-release-history)。

更新安全代理后，您可以通过查看日志来检查安装状态。有关更多信息，请参阅 [正在验证 GuardDuty 安全代理安装状态](installing-gdu-security-agent-ec2-manually.md#validate-ec2-gdu-agent-installation-healthy)。

# 管理 Fargate（仅限 Amazon ECS）的自动安全代理
<a name="managing-gdu-agent-ecs-automated"></a>

运行时监控仅支持通过管理您的 Amazon ECS 集群 (AWS Fargate) 的安全代理 GuardDuty。不支持在 Amazon ECS 集群上手动管理安全代理。

在继续完成本节中的步骤之前，务必要满足[AWS Fargate （仅限 Amazon ECS）支持的先决条件](prereq-runtime-monitoring-ecs-support.md)部分的要求。

根据选择首选方法为您的资源启用 GuardDuty 自动代理。[在 Amazon ECS-Fargate 资源中管理 GuardDuty 安全代理的方法](how-runtime-monitoring-works-ecs-fargate.md#gdu-runtime-approaches-agent-deployment-ecs-clusters)

**Topics**

## 为多账户环境配置 GuardDuty 代理
<a name="ecs-fargate-manage-agent-multiple-accounts"></a>

在多账户环境中，只有委派的 GuardDuty 管理员账户才能启用或禁用成员账户的自动代理配置，以及管理属于其组织中成员账户的 Amazon ECS 集群的自动代理配置。 GuardDuty 成员账户无法修改此配置。委托 GuardDuty 管理员账户使用管理其成员账户 AWS Organizations。有关多账户环境的更多信息，请参阅[中的管理多个账户。 GuardDuty](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_accounts.html)

### 为委派的 GuardDuty 管理员账户启用自动代理配置
<a name="ecs-enable-automated-agent-config-delegatedadmin"></a>

------
#### [ Manage for all Amazon ECS clusters (account level) ]

如果对于“运行时监控”您选择了**为所有账户启用**，您将有以下选项：
+ 在 “自动代理配置” 部分**为所有账户选择 “启用**”。 GuardDuty 将为所有已启动的 Amazon ECS 任务部署和管理安全代理。
+ 选择**手动配置账户**。

如果您在“运行时监控”部分选择了**手动配置账户**，请执行以下操作：

1. 在“自动代理配置”部分下选择**手动配置账户**。

1. 在**委派 GuardDuty 管理员账户（此账户）**部分选择**启用**。

选择**保存**。

如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

有关更新服务的步骤，请参阅以下资源：
+ 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
+ [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
+ 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for all Amazon ECS clusters but exclude some of the clusters (cluster level) ]

1. 向此 Amazon ECS 集群添加一个键值对为 `GuardDutyManaged`-`false` 的标签。

1. 阻止修改标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------

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

1. 在导航窗格中，选择**运行时监控**。

1. 
**注意**  
在为您的账户启用自动代理配置之前，请务必将排除标签添加到您的 Amazon ECS 集群；否则，s GuardDuty idecar 容器将附加到已启动的 Amazon ECS 任务中的所有容器上。

   在**配置**选项卡下，选择**自动代理配置**中的**启用**。

   对于尚未排除的 Amazon ECS 集群， GuardDuty将管理边车容器中安全代理的部署。

1. 选择**保存**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for selective (inclusion only) Amazon ECS clusters (cluster level) ]

1. 向要包含其中所有任务的 Amazon ECS 集群添加标签。键值对必须是 `GuardDutyManaged`-`true`。

1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------
**注意**  
在 Amazon ECS 集群中使用包含标签时，您无需通过自动 GuardDuty 代理配置明确启用代理。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------

### 为所有成员账户自动启用
<a name="ecs-auto-enable-all-member-accounts"></a>

------
#### [ Manage for all Amazon ECS clusters (account level) ]

以下步骤假设您在“运行时监控”部分选择了**为所有账户启用**。

1. 在 “自动代理配置” 部分**为所有账户选择 “启用**”。 GuardDuty 将为所有已启动的 Amazon ECS 任务部署和管理安全代理。

1. 选择**保存**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for all Amazon ECS clusters but exclude some of the clusters (cluster level) ]

1. 向此 Amazon ECS 集群添加一个键值对为 `GuardDutyManaged`-`false` 的标签。

1. 阻止修改标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------

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

1. 在导航窗格中，选择**运行时监控**。

1. 
**注意**  
在为您的账户启用自动代理配置之前，请务必将排除标签添加到您的 Amazon ECS 集群；否则，s GuardDuty idecar 容器将附加到已启动的 Amazon ECS 任务中的所有容器上。

   在**配置**选项卡下，选择**编辑**。

1. 在**自动代理配置**部分选择**为所有账户启用**

   对于尚未排除的 Amazon ECS 集群， GuardDuty将管理边车容器中安全代理的部署。

1. 选择**保存**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for selective (inclusion-only) Amazon ECS clusters (cluster level) ]

无论您是通过哪种方式选择启用运行时监控的，以下步骤都有助您监控组织中所有成员账户的选定 Amazon ECS Fargate 任务。

1. 请勿启用“自动代理配置”部分中的任何配置。确保运行时监控配置与上一步中选择的配置相同。

1. 选择**保存**。

1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------
**注意**  
在 Amazon ECS 集群中使用包含标签时，您无需明确启用**GuardDuty 代理自动管理**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------

### 为现有活动成员账户启用自动代理配置
<a name="ecs-enable-existing-active-member-accounts"></a>

------
#### [ Manage for all Amazon ECS clusters (account level) ]

1. 在“运行时监控”页面的**配置**选项卡下，您可以查看自动代理配置的当前状态。

1. 在“自动代理配置”窗格中的**活动成员账户**部分下，选择**操作**。

1. 在**操作**中，选择**为所有现有活跃成员账户启用**。

1. 选择**确认**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for all Amazon ECS clusters but exclude some of the clusters (cluster level) ]

1. 向此 Amazon ECS 集群添加一个键值对为 `GuardDutyManaged`-`false` 的标签。

1. 阻止修改标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------

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

1. 在导航窗格中，选择**运行时监控**。

1. 
**注意**  
在为您的账户启用自动代理配置之前，请务必将排除标签添加到您的 Amazon ECS 集群；否则，s GuardDuty idecar 容器将附加到已启动的 Amazon ECS 任务中的所有容器上。

   在“自动代理配置”部分的**配置**选项卡下，选择**活动成员账户**下的**操作**。

1. 在**操作**中，选择**为所有活跃成员账户启用**。

   对于尚未排除的 Amazon ECS 集群， GuardDuty将管理边车容器中安全代理的部署。

1. 选择**确认**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for selective (inclusion only) Amazon ECS clusters (cluster level) ]

1. 向要包含其中所有任务的 Amazon ECS 集群添加标签。键值对必须是 `GuardDutyManaged`-`true`。

1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------
**注意**  
为 Amazon ECS 集群使用包含标签时，您无需显式启用**自动代理配置**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------

### 为新成员自动启用自动代理配置
<a name="ecs-auto-enable-new-members-only"></a>

------
#### [ Manage for all Amazon ECS clusters (account level) ]

1. 在“运行时监控”页面上，选择**编辑**以更新现有配置。

1. 在“自动代理配置”部分中选择**为新成员账户自动启用**。

1. 选择**保存**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for all Amazon ECS clusters but exclude some of the clusters (cluster level) ]

1. 向此 Amazon ECS 集群添加一个键值对为 `GuardDutyManaged`-`false` 的标签。

1. 阻止修改标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------

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

1. 在导航窗格中，选择**运行时监控**。

1. 
**注意**  
在为您的账户启用自动代理配置之前，请务必将排除标签添加到您的 Amazon ECS 集群；否则，s GuardDuty idecar 容器将附加到已启动的 Amazon ECS 任务中的所有容器上。

   在**配置**选项卡下，选择**自动代理配置**部分中的**为新成员账户自动启用**。

   对于尚未排除的 Amazon ECS 集群， GuardDuty将管理边车容器中安全代理的部署。

1. 选择**保存**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for selective (inclusion only) Amazon ECS clusters (cluster level) ]

1. 向要包含其中所有任务的 Amazon ECS 集群添加标签。键值对必须是 `GuardDutyManaged`-`true`。

1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------
**注意**  
为 Amazon ECS 集群使用包含标签时，您无需显式启用**自动代理配置**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------

### 有选择地为活动成员账户启用自动代理配置
<a name="ecs-enable-gdu-agent-individual-active-members"></a>

------
#### [ Manage for all Amazon ECS (account level) ]

1. 在“账户”页面上，选择要为其启用运行时监控 – 自动代理配置（ECS-Fargate）的账户。您可以选择多个账户。确保您在此步骤中选择的账户已启用运行时监控。

1. 从**编辑防护计划**中选择相应的选项，以启用**运行时监控 – 自动代理配置（ECS-Fargate）**。

1. 选择**确认**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for all Amazon ECS clusters but exclude some of the clusters (cluster level) ]

1. 向此 Amazon ECS 集群添加一个键值对为 `GuardDutyManaged`-`false` 的标签。

1. 阻止修改标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------

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

1. 在导航窗格中，选择**运行时监控**。

1. 
**注意**  
在为您的账户启用 GuardDuty 代理自动管理之前，请务必将排除标签添加到您的 Amazon ECS 集群；否则，s GuardDuty idecar 容器将附加到已启动的 Amazon ECS 任务中的所有容器上。

   在“账户”页面上，选择要为其启用运行时监控 – 自动代理配置（ECS-Fargate）的账户。您可以选择多个账户。确保您在此步骤中选择的账户已启用运行时监控。

   对于尚未排除的 Amazon ECS 集群， GuardDuty将管理边车容器中安全代理的部署。

1. 从**编辑防护计划**中选择相应的选项，以启用**运行时监控 – 自动代理配置（ECS-Fargate）**。

1. 选择**保存**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------
#### [ Manage for selective (inclusion only) Amazon ECS clusters (cluster level) ]

1. 对于含有要监控的 Amazon ECS 集群的选定账户，要确保您没有为这些账户启用**自动代理配置**或**运行时监控 – 自动代理配置（ECS-Fargate）**。

1. 向要包含其中所有任务的 Amazon ECS 集群添加标签。键值对必须是 `GuardDutyManaged`-`true`。

1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "Null": {
                       "ecs:ResourceTag/GuardDutyManaged": false
                   }
               }
           },
           {
               "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
               "Effect": "Deny",
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],
               "Resource": [
                   "*"
               ],
               "Condition": {
                   "StringNotEquals": {
                       "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },
                   "ForAnyValue:StringEquals": {
                       "aws:TagKeys": [
                           "GuardDutyManaged"
                       ]   
                   }   
               }
           },
           {       
               "Sid": "DenyModifyTagsIfPrinTagNotExists",
               "Effect": "Deny", 
               "Action": [
                   "ecs:TagResource",
                   "ecs:UntagResource"
               ],      
               "Resource": [
                   "*"     
               ],      
               "Condition": {
                   "StringNotEquals": {
                       "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                   },      
                   "Null": {
                       "aws:PrincipalTag/GuardDutyManaged": true
                   }       
               }       
           }
       ]
   }
   ```

------
**注意**  
为 Amazon ECS 集群使用包含标签时，您无需显式启用**自动代理配置**。

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

------

## 为独立账户配置 GuardDuty 代理
<a name="ecs-fargate-manage-agent-standalone-account"></a>

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

1. 在导航窗格中，选择**运行时监控**。

1. 在**配置**选项卡下：

   1. 

**管理所有 Amazon ECS 集群的自动代理配置（账户级别）**

      在 **AWS Fargate （仅限 ECS）**的**自动代理配置**部分中选择**启用**。当新的 Fargate Amazon ECS 任务启动时， GuardDuty 将管理安全代理的部署。

      1. 选择**保存**。

   1. 

**通过排除某些 Amazon ECS 集群来管理自动代理配置（集群级别）**

      1. 向要排除其中所有任务的 Amazon ECS 集群添加标签。键值对必须是 `GuardDutyManaged`-`false`。

      1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

         ```
         {
             "Version":"2012-10-17",		 	 	 
             "Statement": [
                 {
                     "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
                     "Effect": "Deny",
                     "Action": [
                         "ecs:TagResource",
                         "ecs:UntagResource"
                     ],
                     "Resource": [
                         "*"
                     ],
                     "Condition": {
                         "StringNotEquals": {
                             "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                             "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                         },
                         "Null": {
                             "ecs:ResourceTag/GuardDutyManaged": false
                         }
                     }
                 },
                 {
                     "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
                     "Effect": "Deny",
                     "Action": [
                         "ecs:TagResource",
                         "ecs:UntagResource"
                     ],
                     "Resource": [
                         "*"
                     ],
                     "Condition": {
                         "StringNotEquals": {
                             "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                             "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                         },
                         "ForAnyValue:StringEquals": {
                             "aws:TagKeys": [
                                 "GuardDutyManaged"
                             ]   
                         }   
                     }
                 },
                 {       
                     "Sid": "DenyModifyTagsIfPrinTagNotExists",
                     "Effect": "Deny", 
                     "Action": [
                         "ecs:TagResource",
                         "ecs:UntagResource"
                     ],      
                     "Resource": [
                         "*"     
                     ],      
                     "Condition": {
                         "StringNotEquals": {
                             "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                         },      
                         "Null": {
                             "aws:PrincipalTag/GuardDutyManaged": true
                         }       
                     }       
                 }
             ]
         }
         ```

------

      1. 在**配置**选项卡下，选择**自动代理配置**部分中的**启用**。
**注意**  
在为您的账户启用 GuardDuty 代理自动管理之前，请务必将排除标签添加到您的 Amazon ECS 集群；否则，将在相应的 Amazon ECS 集群内启动的所有任务中部署安全代理。

         对于尚未排除的 Amazon ECS 集群， GuardDuty将管理边车容器中安全代理的部署。

      1. 选择**保存**。

   1. 

**通过包含某些 Amazon ECS 集群来管理自动代理配置（集群级别）**

      1. 向要包含其中所有任务的 Amazon ECS 集群添加标签。键值对必须是 `GuardDutyManaged`-`true`。

      1. 阻止修改这些标签，可信实体除外。《AWS Organizations 用户指南》中 [Prevent tags from being modified except by authorized principles](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples_tagging.html#example-require-restrict-tag-mods-to-admin)** 部分提供的策略已经修改，以便在此处适用。

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

****  

         ```
         {
             "Version":"2012-10-17",		 	 	 
             "Statement": [
                 {
                     "Sid": "DenyModifyTagsIfResAuthzTagAndPrinTagDontMatch",
                     "Effect": "Deny",
                     "Action": [
                         "ecs:TagResource",
                         "ecs:UntagResource"
                     ],
                     "Resource": [
                         "*"
                     ],
                     "Condition": {
                         "StringNotEquals": {
                             "ecs:ResourceTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                             "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                         },
                         "Null": {
                             "ecs:ResourceTag/GuardDutyManaged": false
                         }
                     }
                 },
                 {
                     "Sid": "DenyModifyResAuthzTagIfPrinTagDontMatch",
                     "Effect": "Deny",
                     "Action": [
                         "ecs:TagResource",
                         "ecs:UntagResource"
                     ],
                     "Resource": [
                         "*"
                     ],
                     "Condition": {
                         "StringNotEquals": {
                             "aws:RequestTag/GuardDutyManaged": "${aws:PrincipalTag/GuardDutyManaged}",
                             "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                         },
                         "ForAnyValue:StringEquals": {
                             "aws:TagKeys": [
                                 "GuardDutyManaged"
                             ]   
                         }   
                     }
                 },
                 {       
                     "Sid": "DenyModifyTagsIfPrinTagNotExists",
                     "Effect": "Deny", 
                     "Action": [
                         "ecs:TagResource",
                         "ecs:UntagResource"
                     ],      
                     "Resource": [
                         "*"     
                     ],      
                     "Condition": {
                         "StringNotEquals": {
                             "aws:PrincipalArn": "arn:aws:iam::123456789012:role/org-admins/iam-admin"
                         },      
                         "Null": {
                             "aws:PrincipalTag/GuardDutyManaged": true
                         }       
                     }       
                 }
             ]
         }
         ```

------

1. 如果 GuardDuty 要监控属于服务一部分的任务，则需要在启用运行时监控后部署新的服务。如果特定 ECS 服务的上次部署是在启用运行时监控之前启动的，则可以重新启动该服务，也可以使用 `forceNewDeployment` 更新服务。

   有关更新服务的步骤，请参阅以下资源：
   + 《Amazon Elastic Container Service 开发人员指南》中的[使用控制台更新 Amazon ECS 服务](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html)**。
   + [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)在《*亚马逊弹性容器服务 API 参考*》中。
   + 《AWS CLI 命令参考》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)**。

# 自动管理 Amazon EKS 资源的安全代理
<a name="managing-gdu-agent-eks-automatically"></a>

运行时监控支持通过 GuardDuty 自动配置和手动启用安全代理。本节介绍了为 Amazon EKS 集群启用自动代理配置的步骤。

在继续操作之前，请确保您已满足 [Amazon EKS 集群支持的先决条件](prereq-runtime-monitoring-eks-support.md)的要求。

根据您偏好的[通过以下方式管理安全代理 GuardDuty](how-runtime-monitoring-works-eks.md#eks-runtime-using-gdu-agent-management-auto)的方法，相应地选择以下各章节中的步骤。

## 为多账户环境配置自动代理
<a name="eks-runtime-monitoring-agent-manage-multiple-account"></a>

在多账户环境中，只有委派的 GuardDuty 管理员账户才能启用或禁用成员账户的自动代理配置，以及管理属于其组织中成员账户的 EKS 集群的自动代理。 GuardDuty 成员账户无法通过其账户修改此配置。委托 GuardDuty 管理员账户账户使用管理其成员账户 AWS Organizations。有关多账户环境的更多信息，请参阅[管理多个账户](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_accounts.html)。

### 为委派的 GuardDuty 管理员账户配置自动代理配置
<a name="eks-runtime-configure-agent-delegated-admin"></a>


| **管理 GuardDuty 安全代理的首选方法** | **步骤** | 
| --- | --- | 
|  通过以下方式管理安全代理 GuardDuty （监控所有 EKS 集群）  | 如果在“运行时监控”部分中选择了**为所有账户启用**，您将有以下选项： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) 如果您在“运行时监控”部分选择了**手动配置账户**，请执行以下操作： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) 选择**保存**。  | 
| 监控所有 EKS 集群，但排除其中一些集群（使用排除标签） | 从以下过程中，选择一种适合您的场景。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
|  使用包含标签监控选择性 EKS 集群  | 无论您选择通过哪种方式启用运行时监控，以下步骤都将有助您监控账户中的选定 EKS 集群： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
| 手动管理 GuardDuty 安全代理 | 无论您选择通过哪种方式启用运行时监控，都可以手动管理 EKS 集群的安全代理。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) | 

### 为所有成员账户自动启用自动代理
<a name="eks-runtime-monitoring-agent-auto-enable-existing-member-accounts"></a>

**注意**  
更新成员账户的配置可能最长需要 24 小时。


| **管理 GuardDuty 安全代理的首选方法** | **步骤** | 
| --- | --- | 
|  通过以下方式管理安全代理 GuardDuty （监控所有 EKS 集群）  |  本主题旨在为所有成员账户启用运行时监控，因此以下步骤假定您在“运行时监控”部分选择了**为所有账户启用**。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
| 监控所有 EKS 集群，但排除其中一些集群（使用排除标签） | 从以下过程中，选择一种适合您的场景。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
|  使用包含标签监控选择性 EKS 集群  | 无论您选择通过哪种方式启用运行时监控，以下步骤都将有助您监控组织中所有成员账户的选定 EKS 集群： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
| 手动管理 GuardDuty 安全代理 | 无论您选择通过哪种方式启用运行时监控，都可以手动管理 EKS 集群的安全代理。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 

### 为所有现有活动成员账户启用自动代理
<a name="eks-runtime-monitoring-agent-all-active-members"></a>

**注意**  
更新成员账户的配置可能最长需要 24 小时。

**管理组织中现有活跃成员账户 GuardDuty 的安全代理**
+  GuardDuty 要从属于组织中现有活跃成员账户的 EKS 集群接收运行时事件，您必须选择首选方法来管理这些 EKS 集群 GuardDuty 的安全代理。有关每种方法的更多信息，请参阅 [在 Amazon EKS 集群中管理 GuardDuty 安全代理的方法](how-runtime-monitoring-works-eks.md#eksrunmon-approach-to-monitor-eks-clusters)。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)

### 为新成员自动启用自动代理配置
<a name="eks-runtime-monitoring-agent-auto-enable-new-members"></a>


| **管理 GuardDuty 安全代理的首选方法** | **步骤** | 
| --- | --- | 
|  通过以下方式管理安全代理 GuardDuty （监控所有 EKS 集群）  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
| 监控所有 EKS 集群，但排除其中一些集群（使用排除标签） | 从以下过程中，选择一种适合您的场景。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
|  使用包含标签监控选择性 EKS 集群  | 无论您选择通过哪种方式启用运行时监控，以下步骤都将有助您监控组织中新成员账户的选定 EKS 集群。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
|  手动管理 GuardDuty 安全代理  | 无论您选择通过哪种方式启用运行时监控，都可以手动管理 EKS 集群的安全代理。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 

### 有选择地为活动成员账户配置自动代理
<a name="eks-runtime-monitoring-agent-selectively-member-accounts"></a>


| **管理 GuardDuty 安全代理的首选方法** | **步骤** | 
| --- | --- | 
|  通过以下方式管理安全代理 GuardDuty （监控所有 EKS 集群）  | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) | 
|  监控所有 EKS 集群，但排除其中一些集群（使用排除标签）  | 从以下过程中，选择一种适合您的场景。 [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html) [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
|  使用包含标签监控选择性 EKS 集群  |  无论您选择通过哪种方式启用运行时监控，以下步骤都将有助您监控属于选定账户的选定 EKS 集群： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 
|  手动管理 GuardDuty 安全代理  | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)  | 

## 为独立账户配置自动代理
<a name="eks-runtime-monitoring-agent-manage-standalone-account"></a>

独立账户拥有在特定账户中启用或禁用保护计划的决定 AWS 区域。 AWS 账户 

如果您的账户通过或通过 AWS Organizations邀请方式与 GuardDuty 管理员帐户关联，则此部分不适用于您的账户。有关更多信息，请参阅 [为多账户环境启用运行时监控](enable-runtime-monitoring-multiple-acc-env.md)。

启用运行时监控后，请确保通过自动配置或手动部署来安装 GuardDuty 安全代理。在完成以下过程中列出的所有步骤时，务必要安装安全代理。

根据您是要监控全部还是部分 Amazon EKS 资源的偏好，选择一种您偏好的方法并按照下表中的步骤进行操作。

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

1. 在导航窗格中，选择**运行时监控**。

1. 在**配置**选项卡下选择**启用**，以为您的账户启用自动代理配置。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/managing-gdu-agent-eks-automatically.html)

# 手动管理 Amazon EKS 集群的安全代理
<a name="managing-gdu-agent-eks-manually"></a>

本节介绍在启用运行时监控（或 EKS 运行时监控）后如何管理 Amazon EKS 附加GuardDuty 代理（代理）。要使用运行时监控，您必须启用运行时监控并配置 Amazon EKS 附加组件 `aws-guardduty-agent`。您需要执行的两个步骤 GuardDuty 才能检测和生成潜在威胁[GuardDuty 运行时监控查找类型](findings-runtime-monitoring.md)。

要手动管理代理，一个先决条件是创建一个 VPC 端点。这有助于 GuardDuty 接收运行时事件。之后，您可以安装安全代理，这样它 GuardDuty 就可以开始接收来自 Amazon EKS 资源的运行时事件。 GuardDuty 发布此资源的新代理版本时，您可以更新账户中的代理版本。

**Topics**
+ [先决条件 – 创建 Amazon VPC 端点](eksrunmon-prereq-deploy-security-agent.md)
+ [在 Amazon EKS 资源上手动安装 GuardDuty 安全代理](eksrunmon-deploy-security-agent.md)
+ [手动更新 Amazon EKS 资源的安全代理](eksrunmon-update-security-agent.md)

# 先决条件 – 创建 Amazon VPC 端点
<a name="eksrunmon-prereq-deploy-security-agent"></a>

在安装 GuardDuty 安全代理之前，必须先创建亚马逊虚拟私有云 (Amazon VPC) 终端节点。这将有助于 GuardDuty 接收您的 Amazon EKS 资源的运行时事件。

**注意**  
使用 VPC 端点不会产生额外的成本。

选择一种您偏好的访问方法，创建一个 Amazon VPC 端点。

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

**创建 VPC 端点**

1. 打开位于 [https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/) 的 Amazon VPC 控制台。

1. 在导航窗格中的**虚拟私有云**下，选择**端点**。

1. 选择**创建端点**。

1. 在**创建端点**页面​​上，对于**服务类别**，选择**其他端点服务**。

1. 对于**服务名称**，输入 **com.amazonaws.*us-east-1*.guardduty-data**。

   请务必*us-east-1*替换为正确的区域。该区域必须与属于您的 AWS 账户 ID 的 EKS 集群位于同一区域。

1. 选择**验证服务**。

1. 成功验证服务名称后，选择集群所在的 **VPC**。添加以下策略，仅限指定账户使用 VPC 端点。使用此策略下面提供的组织 `Condition`，您可以更新以下策略来限制对端点的访问。要向组织 IDs 中的特定账户提供 VPC 终端节点支持，请参阅[Organization condition to restrict access to your endpoint](#gdu-shared-vpc-endpoint-org)。

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

****  

   ```
   {
   	"Version":"2012-10-17",		 	 	 
   	"Statement": [
   		{
   			"Action": "*",
   			"Resource": "*",
   			"Effect": "Allow",
   			"Principal": "*"
   		},
   		{
   			"Condition": {
   				"StringNotEquals": {
   					"aws:PrincipalAccount": "111122223333" 
   				}
   			},
   			"Action": "*",
   			"Resource": "*",
   			"Effect": "Deny",
   			"Principal": "*"
   		}
   	]
   }
   ```

------

   `aws:PrincipalAccount` 账户 ID 必须与包含 VPC 和 VPC 端点的账户匹配。以下列表显示了如何与其他人共享 VPC 终端节点 AWS 账户 IDs：

**限制访问端点的组织条件**
   + 要指定多个账户访问 VPC 端点，请将 `"aws:PrincipalAccount": "111122223333"` 替换为以下内容：

     ```
     "aws:PrincipalAccount": [
               "666666666666",
               "555555555555"
         ]
     ```
   + 要允许组织中的所有成员访问 VPC 端点，请将 `"aws:PrincipalAccount": "111122223333"` 替换为以下内容：

     ```
     "aws:PrincipalOrgID": "o-abcdef0123"
     ```
   + 要限制组织 ID 的访问资源，请将您的 `ResourceOrgID` 添加到策略中。

     有关更多信息，请参阅 [ResourceOrgID](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceorgid)。

     ```
     "aws:ResourceOrgID": "o-abcdef0123"
     ```

1. 在**其他设置**下，选择**启用 DNS 名称**。

1. 在**子网**下，选择集群所在的子网。

1. 在**安全组**下，选择从 VPC（或 EKS 集群）启用了入站端口 443 的安全组。如果您还没有启用入站端口 443 的安全组，请[创建安全组](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/working-with-security-groups.html#creating-security-group)。

   如果将入站权限限定为您的 VPC（或实例）时出现问题，您可以从任何 IP 地址 `(0.0.0.0/0)` 提供入站 443 端口支持。但是， GuardDuty 建议使用与您的 VPC 的 CIDR 块相匹配的 IP 地址。有关更多信息，请参阅《Amazon VPC 用户指南》中的 [VPC CIDR 块](https://docs.aws.amazon.com//vpc/latest/userguide/vpc-cidr-blocks.html)**。

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

**创建 VPC 端点**
+ 调用[CreateVpcEndpoint](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateVpcEndpoint.html)。
+ 为参数使用以下值：
  + 对于**服务名称**，输入 **com.amazonaws.*us-east-1*.guardduty-data**。

    请务必*us-east-1*替换为正确的区域。该区域必须与属于您的 AWS 账户 ID 的 EKS 集群位于同一区域。
  + 对于 [DNSOptions](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DnsOptions.html)，启用私有 DNS 选项，将其设置为`true`。
+ 有关信息 AWS Command Line Interface，请参阅[create-vpc-endpoint](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/create-vpc-endpoint.html)。

------

完成这些步骤后，请参阅[验证 VPC 端点配置](validate-vpc-endpoint-config-runtime-monitoring.md)以确保 VPC 端点的设置正确。

# 在 Amazon EKS 资源上手动安装 GuardDuty 安全代理
<a name="eksrunmon-deploy-security-agent"></a>

本节介绍如何首次为特定 EKS 集群部署 GuardDuty 安全代理。在继续本节内容之前，确保您已满足了先决条件并为账户启用了运行时监控。如果您不启用运行时监控，则 GuardDuty安全代理（EKS 附加组件）将无法运行。

选择您的首选访问方法以首次部署 GuardDuty 安全代理。

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

1. 在 [https://console.aws.amazon.com/eks/home\$1/](https://console.aws.amazon.com/eks/home#/clusters) clusters 中打开 Amazon EKS 控制台。

1. 选择**集群名称**。

1. 选择**附加组件**选项卡。

1. 选择**获取更多附加组件**。

1. 在**选择插件**页面上，选择 **Amazon GuardDuty EKS 运行时监控**。

1. GuardDuty 建议选择最新的和默认的代理**版本**。

1. 在**配置选定插件设置**页面上，使用默认设置。如果您的 EKS 附加组件的**状态**为 “**需要激活**”，请选择 “**激活**” GuardDuty。此操作将打开 GuardDuty 控制台，为您的账户配置运行时监控。

1. 为账户配置运行时监控后，切换回 Amazon EKS 控制台。您的 EKS 插件的**状态**应变为**准备安装**。

1. 

**（可选）提供 EKS 附加组件配置架构**

   对于附加**版本**，如果您选择 **v1.5.0 或更**高版本，则运行时监控支持配置代理的 GuardDuty 特定参数。有关参数范围的信息，请参阅[配置 EKS 附加组件参数](guardduty-configure-security-agent-eks-addon.md)。

   1. 展开**可选配置设置**，以查看可配置参数及其预期值和格式。

   1. 设置参数。值必须在 [配置 EKS 附加组件参数](guardduty-configure-security-agent-eks-addon.md) 中提供的范围内。

   1. 选择**保存更改**，以根据高级配置创建附加组件。

   1. 对于**冲突解决方法**，如果将参数的值更新为非默认值，则将使用您选择的选项来解决冲突。有关所列选项的更多信息，请参阅《Amazon EKS API 参考》中的 [resolveConflicts](https://docs.aws.amazon.com/eks/latest/APIReference/API_UpdateAddon.html#AmazonEKS-UpdateAddon-request-resolveConflicts)**。

1. 选择**下一步**。

1. 在**查看和创建**页面上，验证所有详细信息，然后选择**创建**。

1. 导航回集群详细信息，然后选择**资源**选项卡。

1. 您可以查看带有前缀的新窗格**aws-guardduty-agent**。

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

您可以使用以下任一选项来配置 Amazon EKS 插件代理（`aws-guardduty-agent`）：
+ [CreateAddon](https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateAddon.html)为你的账户跑步。
+ 
**注意**  
对于插件`version`，如果您选择 **v1.5.0 或更高**版本，则运行时监控支持配置代理的 GuardDuty 特定参数。有关更多信息，请参阅 [配置 EKS 附加组件参数](guardduty-configure-security-agent-eks-addon.md)。

  对请求参数使用以下值：
  + 对于 `addonName`，输入 `aws-guardduty-agent`。

    在使用附加版本`v1.5.0`或更高版本支持的可配置值时，可以使用以下 AWS CLI 示例。务必要将以红色突出显示的占位符值以及相关的 `Example.json` 替换为配置的值。

    ```
    aws eks create-addon --region us-east-1 --cluster-name myClusterName --addon-name aws-guardduty-agent --addon-version v1.12.1-eksbuild.2 --configuration-values 'file://example.json'
    ```  
**Example.json**  

    ```
    {
    	"priorityClassName": "aws-guardduty-agent.priorityclass-high",
    	"dnsPolicy": "Default",
    	"resources": {
    		"requests": {
    			"cpu": "237m",
    			"memory": "512Mi"
    		},
    		"limits": {
    			"cpu": "2000m",
    			"memory": "2048Mi"
    		}
    	}	
    }
    ```
  + 有关支持的 `addonVersion` 的信息，请参阅 [安全代理支持的 Kubernetes 版本 GuardDuty](prereq-runtime-monitoring-eks-support.md#gdu-agent-supported-k8-version)。
+ 或者，你可以使用 AWS CLI。有关更多信息，请参阅 [create-addon](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/eks/create-addon.html)。

------

**VPC 端点的私有 DNS 名称**  
默认情况下，安全代理会解析并连接到 VPC 端点的私有 DNS 名称。对于非 FIPS 端点，您的私有 DNS 将按以下格式显示：  
非 FIPS 端点 – `guardduty-data.us-east-1.amazonaws.com`  
 AWS 区域、*us-east-1*、将根据您所在的地区而变化。

# 手动更新 Amazon EKS 资源的安全代理
<a name="eksrunmon-update-security-agent"></a>

当你手动管理 GuardDuty 安全代理时，你有责任为你的账户更新安全代理。如需获得新代理版本的通知，您可以订阅 [GuardDuty 安全代理发布版本](runtime-monitoring-agent-release-history.md) RSS 源。

您可以将安全代理更新到最新版本，以受益于新增的支持和改进。如果您当前的代理版本已接近标准支持结束日期，则要继续使用运行时监控（或 EKS 运行时监控），则必须更新到下一个可用版本或最新的代理版本。

**先决条件**  
在更新安全代理版本之前，请确保您当前计划使用的代理版本与您的 Kubernetes 版本兼容。有关更多信息，请参阅 [安全代理支持的 Kubernetes 版本 GuardDuty](prereq-runtime-monitoring-eks-support.md#gdu-agent-supported-k8-version)。

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

1. 在 [https://console.aws.amazon.com/eks/home\$1/](https://console.aws.amazon.com/eks/home#/clusters) clusters 中打开 Amazon EKS 控制台。

1. 选择**集群名称**。

1. 在**集群信息**下，选择**附加组件**选项卡。

1. 在 “**插件**” 选项卡下，选择 “**GuardDutyEKS 运行时监控**”。

1. 选择**编辑**以更新代理详细信息。

1. 在**配置 GuardDuty EKS 运行时监控**页面上，更新详细信息。

1. 

**（可选）更新可选配置设置**

   如果您的 EKS 附加组件**版本**为 *1.5.0* 或更高版本，则还可以更新附加组件配置架构。

   1. 展开**可选配置设置**以查看配置架构。

   1. 根据[配置 EKS 附加组件参数](guardduty-configure-security-agent-eks-addon.md)中提供的范围更新参数值。

   1. 选择**保存更改**以开始更新。

   1. 对于**冲突解决方法**，如果将参数的值更新为非默认值，则将使用您选择的选项来解决冲突。有关所列选项的更多信息，请参阅《Amazon EKS API 参考》中的 [resolveConflicts](https://docs.aws.amazon.com/eks/latest/APIReference/API_UpdateAddon.html#AmazonEKS-UpdateAddon-request-resolveConflicts)**。

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

要更新您的 Amazon EKS 集群 GuardDuty 的安全代理，请参阅[更新插件](https://docs.aws.amazon.com/eks/latest/userguide/managing-add-ons.html#updating-an-add-on)。

**注意**  
对于插件`version`，如果您选择 **1.5.0 或更高**版本，则运行时监控支持配置 GuardDuty 代理的特定参数。有关参数范围的信息，请参阅[配置 EKS 附加组件参数](guardduty-configure-security-agent-eks-addon.md)。

在使用附加版本 *1.5.0 及更高*版本支持的可配置值时，可以使用以下 AWS CLI 示例。务必要将以红色突出显示的占位符值以及相关的 `Example.json` 替换为配置的值。

```
aws eks update-addon --region us-east-1 --cluster-name myClusterName --addon-name aws-guardduty-agent --addon-version v1.12.1-eksbuild.2 --configuration-values 'file://example.json'
```

**Example.json**  

```
{
	"priorityClassName": "aws-guardduty-agent.priorityclass-high",
	"dnsPolicy": "Default",
	"resources": {
		"requests": {
			"cpu": "237m",
			"memory": "512Mi"
		},
		"limits": {
			"cpu": "2000m",
			"memory": "2048Mi"
		}
	}	
}
```

------

如果您的 Amazon EKS 附加组件版本为 1.5.0 或更高版本，并且您已配置了附加组件架构，则可以验证为集群显示的值是否正确。有关更多信息，请参阅 [验证配置架构更新](guardduty-configure-security-agent-eks-addon.md#gdu-verify-eks-add-on-configuration-param)。

# 为 Amazon EKS 配置 GuardDuty 安全代理（附加组件）参数
<a name="guardduty-configure-security-agent-eks-addon"></a>

您可以为 Amazon EKS 配置 GuardDuty 安全代理的特定参数。此支持适用于 GuardDuty 安全代理版本 1.5.0 及更高版本。有关最新附加组件版本的信息，请参阅[GuardDuty Amazon EKS 资源的安全代理版本](runtime-monitoring-agent-release-history.md#eks-runtime-monitoring-agent-release-history)。

**我为什么要更新安全代理配置架构**  
在 Amazon EKS 集群中的所有容器中， GuardDuty 安全代理的配置架构都是相同的。当默认值与相关工作负载和实例大小不一致时，可以考虑配置 CPU 设置、内存设置、`PriorityClass` 和 `dnsPolicy` 设置。无论您如何管理 Amazon EKS 集群的 GuardDuty 代理，都可以配置或更新这些参数的现有配置。

## 配置了参数的自动配置代理配置行为
<a name="preserve-config-param-eks-addon-auto-managed"></a>

代表您 GuardDuty 管理安全代理（EKS 附加组件）时，它会根据需要更新插件。 GuardDuty 会将可配置参数的值设置为默认值。但您仍然可以将参数更新为需要的值。如果这导致冲突，则默认的 [resolveConflicts](https://docs.aws.amazon.com/eks/latest/APIReference/API_UpdateAddon.html#AmazonEKS-UpdateAddon-request-resolveConflicts) 选项为 `None`。

## 可配置的参数和值
<a name="gdu-eks-addon-configure-parameters-values"></a>

有关配置附加组件参数的步骤的信息，请参阅：
+ [在 Amazon EKS 资源上手动安装 GuardDuty 安全代理](eksrunmon-deploy-security-agent.md)，或者
+ [手动更新 Amazon EKS 资源的安全代理](eksrunmon-update-security-agent.md)

以下表格列举了可用于手动部署 Amazon EKS 附加组件或更新现有附加组件设置的范围和值。

**CPU 设置**      
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/guardduty-configure-security-agent-eks-addon.html)

**内存设置**      
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/guardduty-configure-security-agent-eks-addon.html)

**`PriorityClass` 设置**  
在 GuardDuty 为您创建 Amazon EKS 加载项时，分配的`PriorityClass`为`aws-guardduty-agent.priorityclass`。这意味着不会根据代理容器组（pod）的优先级执行任何操作。您可以选择以下 `PriorityClass` 选项之一来配置此附加组件参数：      
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/guardduty/latest/ug/guardduty-configure-security-agent-eks-addon.html)
**1** Kubernetes 提供了两个 `PriorityClass` 选项，分别为 `system-cluster-critical` 和 `system-node-critical`。有关更多信息，请参阅 *Kubernetes 文档[PriorityClass](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#how-to-use-priority-and-preemption)*中的。

**`dnsPolicy` 设置**  
选择 Kubernetes 支持的以下 DNS 策略选项之一。如果未指定任何配置，则将使用默认值 `ClusterFirst`。  
+ `ClusterFirst`
+ `ClusterFirstWithHostNet`
+ `Default`
有关这些策略的更多信息，请参阅《Kubernetes 文档》中的 [Pod's DNS Policy](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy)**。

## 验证配置架构更新
<a name="gdu-verify-eks-add-on-configuration-param"></a>

配置好参数后，请执行以下步骤来验证配置架构是否已更新：

1. 在 [https://console.aws.amazon.com/eks/home\$1/](https://console.aws.amazon.com/eks/home#/clusters) clusters 中打开 Amazon EKS 控制台。

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

1. 在**集群**页面上，选择要验证更新的**集群名称**。

1. 选择**资源**选项卡。

1. 从 “**资源类型**” 窗格的 “**工作负载**” 下选择**DaemonSets**。

1. 选择 **aws-guardduty-agent**。

1. 在该**aws-guardduty-agent**页面上，选择 **Raw view 以查看**未格式化的 JSON 响应。验证可配置参数是否显示您提供的值。

验证后，切换到 GuardDuty 控制台。选择相应的， AWS 区域 然后查看您的 Amazon EKS 集群的覆盖状态。有关更多信息，请参阅 [Amazon EKS 集群的运行时覆盖率和故障排除](eks-runtime-monitoring-coverage.md)。

# 验证 VPC 端点配置
<a name="validate-vpc-endpoint-config-runtime-monitoring"></a>

手动或通过 GuardDuty 自动配置安装安全代理后，您可以使用本文档来验证 VPC 终端节点的配置。您也可以在排除任何资源类型的任何[运行时覆盖率问题](https://docs.aws.amazon.com/guardduty/latest/ug/runtime-monitoring-assessing-coverage.html)后使用这些步骤。这样可以确保步骤按预期运行，并且覆盖率状态可能会显示为**正常**。

使用以下步骤来验证是否在 VPC 所有者账户中正确设置了资源类型的 VPC 端点配置：

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

1. 在导航窗格中的**虚拟私有云**下，选择**您的 VPCs**。

1. 在**您的 VPCs**页面上，选择与您的 **VPC ID** 关联的 **IPv4 CIDR**。

1. 在导航窗格中的**虚拟私有云**下，选择**端点**。

1. 在**终端节点**表中，选择**服务名称**与 **com.amazonaws 相似的行。 *us-east-1*.guardduty**-data。区域 (`us-east-1`) 可能与您的端点所在区域不同。

1. 这时将出现一个包含端点详细信息的面板。在**安全组**选项卡下，选择相关**组 ID** 链接以了解更多详细信息。

1. 在**安全组**表中，选择具有相关**安全组 ID** 的行以查看详细信息。

1. **在**入站规则**选项卡下，确保有一个入口策略，其**端口范围**为 **443**，**源**作为从 CIDR 复制的IPv4 值。**入站规则控制允许到达实例的传入流量。下图显示了与安全代理使用的 VPC 关联 GuardDuty 的安全组的入站规则。

   如果您还没有启用了入站端口 443 的安全组，请参阅《Amazon EC2 用户指南》中的[创建安全组](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/working-with-security-groups.html#creating-security-group)**。

   如果将入站权限限定为您的 VPC（或集群）时出现问题，，请为来自任何 IP 地址 (0.0.0.0/0) 的入站 443 端口提供支持。

以下列表包含安装或更新安全代理后需要注意的事项。

**评估运行时覆盖率**  
安装或更新安全代理后，下一步是评估资源的运行时覆盖率。如果运行时覆盖率状态为**不正常**，则必须对问题进行故障排除。有关更多信息，请参阅 [运行时覆盖率问题和故障排除](runtime-monitoring-assessing-coverage.md)。  
如果运行时覆盖率状态显示为**正常**，则表示运行时监控能够收集和接收运行时事件。有关事件列表，请参阅[收集的运行时事件类型](runtime-monitoring-collected-events.md)。

**端点的私有 DNS 名称**  
为您的资源安装 GuardDuty 安全代理后，默认情况下，它将解析并连接到 VPC 终端节点的私有 DNS 名称。对于非 FIPS 端点，私有 DNS 将按以下格式显示：  
`guardduty-data.us-east-1.amazonaws.com`  
 AWS 区域、*us-east-1*、将根据您所在的地区而变化。

**一台主机可能安装了两个安全代理**  
使用 Amazon EC2 实例 GuardDuty 的安全代理时，您可以在 Amazon EKS 集群中的底层主机上安装和使用该代理。如果您已经在该 EKS 集群上部署了安全代理，则同一台主机上可能会同时运行两个安全代理。有关此场景下 GuardDuty 的工作原理的信息，请参阅[在同一主机上的安全代理](two-security-agents-installed-on-ec2-node.md)。