

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

# 管理 Fargate 的自動化安全代理程式 （僅限 Amazon ECS)
<a name="managing-gdu-agent-ecs-automated"></a>

執行期監控僅支援透過 GuardDuty 管理 Amazon ECS 叢集 (AWS Fargate) 的安全代理程式。不支援在 Amazon ECS 叢集上手動管理安全代理程式。

繼續本節中的步驟之前，請務必遵循 [AWS Fargate （僅限 Amazon ECS) 支援的先決條件](prereq-runtime-monitoring-ecs-support.md)。

根據 [在 Amazon ECS-Fargate 資源中管理 GuardDuty 安全代理程式的方法](how-runtime-monitoring-works-ecs-fargate.md#gdu-runtime-approaches-agent-deployment-ecs-clusters)，選擇偏好的方法來為您的資源啟用 GuardDuty 自動化代理程式。

**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) *服務*。
+ Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
+ 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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. 前往 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/) 開啟 GuardDuty 主控台。

1. 在導覽窗格中，選擇**執行期監控**。

1. 
**注意**  
在為您的帳戶啟用自動代理程式組態之前，請務必將排除標籤新增至 Amazon ECS 叢集；否則 GuardDuty 附屬容器會連接至啟動的 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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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. 前往 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/) 開啟 GuardDuty 主控台。

1. 在導覽窗格中，選擇**執行期監控**。

1. 
**注意**  
在為您的帳戶啟用自動代理程式組態之前，請務必將排除標籤新增至 Amazon ECS 叢集；否則 GuardDuty 附屬容器會連接至啟動的 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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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. 前往 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/) 開啟 GuardDuty 主控台。

1. 在導覽窗格中，選擇**執行期監控**。

1. 
**注意**  
在為您的帳戶啟用自動代理程式組態之前，請務必將排除標籤新增至 Amazon ECS 叢集；否則 GuardDuty 附屬容器會連接至啟動的 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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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. 前往 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/) 開啟 GuardDuty 主控台。

1. 在導覽窗格中，選擇**執行期監控**。

1. 
**注意**  
在為您的帳戶啟用自動代理程式組態之前，請務必將排除標籤新增至 Amazon ECS 叢集；否則 GuardDuty 附屬容器會連接至啟動的 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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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. 前往 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/) 開啟 GuardDuty 主控台。

1. 在導覽窗格中，選擇**執行期監控**。

1. 
**注意**  
在為您的帳戶啟用 GuardDuty 代理程式自動管理之前，請務必將排除標籤新增至 Amazon ECS 叢集；否則 GuardDuty 附屬容器會連接至啟動的 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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *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 管理主控台 ，並在 [https://console.aws.amazon.com/guardduty/](https://console.aws.amazon.com/guardduty/)：// 開啟 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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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 使用者指南*中的[授權原則之外，防止標籤遭到修改](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) *服務*。
   + Amazon Elastic Container Service API 參考中的 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html)。 **
   + 《 *AWS CLI 命令參考*》中的 [update-service](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html)。