

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

# 管理 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)**。