

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

# AWS Fargate （僅限 Amazon ECS) 支援的先決條件
<a name="prereq-runtime-monitoring-ecs-support"></a>

本節包含監控 Fargate-Amazon ECS 資源執行時間行為的先決條件。符合這些先決條件後，請參閱 [啟用 GuardDuty 執行期監控](runtime-monitoring-configuration.md)。

**Topics**
+ [驗證架構需求](#validating-architecture-req-ecs)
+ [容器映像存取的先決條件](#before-enable-runtime-monitoring-ecs)
+ [在多帳戶環境中驗證您的組織服務控制政策](#validate-organization-scp-ecs)
+ [驗證角色許可和政策許可界限](#guardduty-runtime-monitoring-ecs-permission-boundary)
+ [CPU 和記憶體限制](#ecs-runtime-agent-cpu-memory-limits)

## 驗證架構需求
<a name="validating-architecture-req-ecs"></a>

您使用的平台可能會影響 GuardDuty 安全代理程式如何支援 GuardDuty 從 Amazon ECS 叢集接收執行期事件。您必須確認您使用的是經過驗證的平台之一。

**初始考量：**  
Amazon ECS 叢集的 AWS Fargate 平台必須是 Linux。對應的平台版本必須至少為 `1.4.0`、 或 `LATEST`。如需平台版本的詳細資訊，請參閱《*Amazon Elastic Container Service 開發人員指南*》中的 [Linux 平台版本](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform-linux-fargate.html)。  
尚不支援 Windows 平台版本。

### 已驗證的平台
<a name="ecs-verified-platforms-gdu-agent"></a>

作業系統分佈和 CPU 架構會影響 GuardDuty 安全代理程式提供的支援。下表顯示部署 GuardDuty 安全代理程式和設定執行期監控的已驗證組態。


| 作業系統分佈**[1](#runtime-monitoring-ecs-os-support)**  | 核心支援 | CPU 架構 x64 (AMD64) | CPU 架構 Graviton (ARM64) | 
| --- | --- | --- | --- | 
| Linux | eBPF、Tracepoints、Kprobe | 支援 | 支援 | <a name="runtime-monitoring-ecs-os-support"></a>

1支援各種作業系統 - GuardDuty 已驗證對上表中所列操作分佈的執行期監控支援。雖然 GuardDuty 安全代理程式可能會在上表中未列出的作業系統上執行，但 GuardDuty 團隊無法保證預期的安全值。

## 容器映像存取的先決條件
<a name="before-enable-runtime-monitoring-ecs"></a>

下列先決條件可協助您從 Amazon ECR 儲存庫存取 GuardDuty 附屬容器映像。

### 許可需求
<a name="ecs-runtime-permissions-requirements"></a>

任務執行角色需要特定 Amazon Elastic Container Registry (Amazon ECR) 許可，才能下載 GuardDuty 安全代理程式容器映像：

```
...
      "ecr:GetAuthorizationToken",
      "ecr:BatchCheckLayerAvailability",
      "ecr:GetDownloadUrlForLayer",
      "ecr:BatchGetImage",
...
```

若要進一步限制 Amazon ECR 許可，您可以新增託管 GuardDuty 安全代理程式的 Amazon ECR 儲存庫 URI AWS Fargate （僅限 Amazon ECS)。如需詳細資訊，請參閱[託管 GuardDuty 代理程式的 Amazon ECR 儲存庫](runtime-monitoring-ecr-repository-gdu-agent.md)。

您可以使用 [AmazonECSTaskExecutionRolePolicy](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_execution_IAM_role.html) 受管政策，或將上述許可新增至`TaskExecutionRole`政策。

### 任務定義組態
<a name="ecs-runtime-task-definition"></a>

建立或更新 Amazon ECS 服務時，您需要在任務定義中提供子網路資訊：

在 Amazon Elastic Container Service APIs 參考中執行 [CreateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html) 和 [UpdateService](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html) API 需要您傳遞子網路資訊。 **如需詳細資訊，請參閱《[Amazon Elastic Container Service 開發人員指南》中的 Amazon ECS 任務定義](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html)。 **

### 網路連線需求
<a name="ecs-runtime-network-requirements"></a>

您必須確保網路連線，才能從 Amazon ECR 下載 GuardDuty 容器映像。此要求專屬於 GuardDuty，因為它使用 Amazon ECR 託管其安全代理程式。根據您的網路組態，您需要實作下列其中一個選項：

**選項 1 - 使用公有網路存取 （如果可用）**  
如果您的 Fargate 任務在具有傳出網際網路存取的子網路中執行，則不需要額外的網路組態。

**選項 2 - 使用 Amazon VPC 端點 （適用於私有子網路）**  
如果您的 Fargate 任務在沒有網際網路存取的情況下在私有子網路中執行，您必須為 ECR 設定 VPC 端點，以確保託管 GuardDuty 安全代理程式的 ECR 儲存庫 URI 可供網路存取。如果沒有這些端點，私有子網路中的任務將無法下載 GuardDuty 容器映像。  
如需 VPC 端點設定指示，請參閱[《Amazon Elastic Container Registry 使用者指南》中的為 Amazon ECR 建立 VPC 端點](https://docs.aws.amazon.com/AmazonECR/latest/userguide/vpc-endpoints.html#ecr-setting-up-vpc-create)。 **

如需有關啟用 Fargate 下載 GuardDuty 容器的資訊，請參閱[《Amazon Elastic Container Registry 使用者指南》中的搭配 Amazon ECS 使用 Amazon ECR 映像](https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_on_ECS.html)。 **

### 安全群組組態
<a name="ecs-runtime-security-group-requirements"></a>

GuardDuty 容器映像位於 Amazon ECR 中，且需要 Amazon S3 存取。此要求專用於從 Amazon ECR 下載容器映像。對於網路存取受限的任務，您必須設定安全群組以允許存取 S3。

在安全群組中新增傳出規則，允許流量流向[連接埠 443 上的 S3 受管字首清單 (`pl-xxxxxxxx`)](https://docs.aws.amazon.com/vpc/latest/privatelink/gateway-endpoints.html#gateway-endpoint-security)。若要新增傳出規則，請參閱《*Amazon VPC 使用者指南*》中的[設定安全群組規則](https://docs.aws.amazon.com/vpc/latest/userguide/working-with-security-group-rules.html)。

若要在主控台中檢視您的 AWS受管字首清單或使用 AWS Command Line Interface (AWS CLI) 來描述它們，請參閱《*Amazon VPC 使用者指南*》中的 [AWS受管字首清單](https://docs.aws.amazon.com/vpc/latest/userguide/working-with-aws-managed-prefix-lists.html)。

## 在多帳戶環境中驗證您的組織服務控制政策
<a name="validate-organization-scp-ecs"></a>

本節說明如何驗證您的服務控制政策 (SCP) 設定，以確保執行期監控在整個組織中如預期般運作。

如果您已設定一或多個服務控制政策來管理組織中的許可，則必須驗證它不會拒絕`guardduty:SendSecurityTelemetry`動作。如需 SCPs如何運作的詳細資訊，請參閱*AWS Organizations 《 使用者指南*》中的 [SCP 評估](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_evaluation.html)。

如果您是成員帳戶，請與相關聯的委派管理員連線。如需有關管理組織 SCPs 的資訊，請參閱*AWS Organizations 《 使用者指南*》中的[服務控制政策 (SCPs)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html)。

針對您在多帳戶環境中設定的所有 SCPs，執行下列步驟：

**在 SCP 中`guardduty:SendSecurityTelemetry`不會拒絕驗證**

1. 登入 Organizations 主控台，網址為 https：//[https://console.aws.amazon.com/organizations/](https://console.aws.amazon.com/organizations/)。您必須以 IAM 角色身分登入，或以組織的管理帳戶中的根使用者身分登入 [（不建議）](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#lock-away-credentials)。

1. 在左導覽窗格中，選取 **Policies (政策)**。然後，在**支援的政策類型**下，選取**服務控制政策**。

1. 在**服務控制政策**頁面上，選擇您要驗證的政策名稱。

1. 在政策的詳細資訊頁面上，檢視此政策**的內容**。請確定它不會拒絕`guardduty:SendSecurityTelemetry`動作。

   下列 SCP 政策是*不拒絕*`guardduty:SendSecurityTelemetry`動作的範例：

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
       "Effect": "Allow",
               "Action": [           
                   "guardduty:SendSecurityTelemetry"
               ],
               "Resource": "*"
           }
       ]
   }
   ```

------

   如果您的政策拒絕此動作，您必須更新政策。如需詳細資訊，請參閱 *AWS Organizations User Guide* 中的 [Update a service control policy (SCP)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_policies_update.html#update_policy)。

## 驗證角色許可和政策許可界限
<a name="guardduty-runtime-monitoring-ecs-permission-boundary"></a>

使用下列步驟來驗證與角色及其政策相關聯的許可界限**不會**限制`guardduty:SendSecurityTelemetry`動作。

**檢視角色及其政策的許可界限**

1. 登入 AWS 管理主控台 並開啟位於 https：//[https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/) 的 IAM 主控台。

1. 在左側導覽窗格中的**存取管理**下，選擇**角色**。

1. 在**角色**頁面上，選取*`TaskExecutionRole`*您可能已建立的角色。

1. 在所選角色的頁面的**許可**索引標籤下，展開與此角色相關聯的政策名稱。然後，驗證此政策不會限制 `guardduty:SendSecurityTelemetry`。

1. 如果已設定**許可界限**，請展開本節。然後，展開每個政策，以檢閱其不會限制`guardduty:SendSecurityTelemetry`動作。政策看起來應該與此 類似[Example SCP policy](#ecs-runtime-scp-not-deny-policy-example)。

   視需要執行下列其中一個動作：
   + 若要修改政策，請選取**編輯**。在此政策的**修改許可**頁面上，更新政策**編輯器中的政策**。請確定 JSON 結構描述仍然有效。然後選擇**下一步**。然後，您可以檢閱和儲存變更。
   + 若要變更此許可界限並選擇另一個界限，請選擇**變更界限**。
   + 若要移除此許可界限，請選擇**移除界限**。

   如需有關管理政策的資訊，請參閱《*IAM 使用者指南*》中的 [中的政策和許可 AWS Identity and Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html)。

## CPU 和記憶體限制
<a name="ecs-runtime-agent-cpu-memory-limits"></a>

在 Fargate 任務定義中，您必須在任務層級指定 CPU 和記憶體值。下表顯示任務層級 CPU 和記憶體值的有效組合，以及 GuardDuty 容器對應的 GuardDuty 安全代理程式最大記憶體限制。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/guardduty/latest/ug/prereq-runtime-monitoring-ecs-support.html)

啟用執行期監控並評估叢集的涵蓋範圍狀態為**良好**之後，您可以設定和檢視容器洞見指標。如需詳細資訊，[在 Amazon ECS 叢集上設定監控](runtime-monitoring-setting-cpu-mem-monitoring.md#ecs-runtime-cpu-memory-monitoring-agent)。

下一個步驟是設定執行期監控，以及設定安全代理程式。