Datadog Security を使用するための AWS Fargate 構成ガイド

このガイドでは、AWS Fargate 上で Cloud SecuritySoftware Composition Analysis (SCA)Threat Detection and Protection (AAP)、および Cloud SIEM を構成する手順を説明します。

Cloud Security、AAP、Cloud SIEM が AWS Fargate 上でどのように構成されるかを示すフロー チャート

AWS Fargate をフルスタックでカバー

Datadog Security は、AWS Fargate を多層的に可視化します。次の表に示すように、これらの製品を互いに組み合わせて使用することで、あらゆる要素をカバーできます。

Fargate アセット

アセット可観測性脆弱性と誤構成の是正脅威検知とレスポンス
Fargate アプリケーションApplication Performance MonitoringSoftware Composition Analysis (SCA) and Code SecurityAAP - Threat Detection and Protection
Fargate インフラストラクチャーInfrastructure MonitoringCloud SecurityWorkload Protection

Fargate 関連リソース

アセット可観測性脆弱性と誤構成の是正脅威検知とレスポンス
AWS IAM のロールとポリシーLog ManagementCloud SecurityCloud SIEM
AWS データベースLog ManagementCloud SecurityCloud SIEM
AWS S3 バケットLog ManagementCloud SecurityCloud SIEM

Cloud Security

前提条件

  • AWS アカウントに対して Datadog AWS インテグレーションがインストールされ、構成されていること。
  • AWS マネジメントコンソールへのアクセス権
  • AWS Fargate ECS または EKS のワークロード
パフォーマンスと信頼性に関するさらなるインサイトを得るため、Datadog は Cloud Security と併用して Infrastructure Monitoring を有効化することを推奨します。

画像

  • cws-instrumentation-init: public.ecr.aws/datadog/cws-instrumentation:latest
  • datadog-agent: public.ecr.aws/datadog/agent:latest

インストール

AWS コンソール

  1. AWS マネジメントコンソールにサインインします。
  2. ECS セクションに移動します。
  3. 左のメニューから Task Definitions を選択し、Create new Task Definition with JSON を選択します。または、既存の Fargate タスク定義を選択します。
  4. 新しいタスク定義を作成するには、JSON 定義を使用するか、AWS CLI メソッドを使用します。
  5. Create をクリックしてタスク定義を作成します。

AWS CLI

  1. datadog-agent-cws-ecs-fargate.json をダウンロードします。

datadog-agent-cws-ecs-fargate.json

{
    "family": "<YOUR_TASK_NAME>",
    "cpu": "256",
    "memory": "512",
    "networkMode": "awsvpc",
    "pidMode": "task",
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "containerDefinitions": [
        {
            "name": "cws-instrumentation-init",
            "image": "public.ecr.aws/datadog/cws-instrumentation:latest",
            "essential": false,
            "user": "0",
            "command": [
                "/cws-instrumentation",
                "setup",
                "--cws-volume-mount",
                "/cws-instrumentation-volume"
            ],
            "mountPoints": [
                {
                    "sourceVolume": "cws-instrumentation-volume",
                    "containerPath": "/cws-instrumentation-volume",
                    "readOnly": false
                }
            ]
        },
        {
            "name": "datadog-agent",
            "image": "public.ecr.aws/datadog/agent:latest",
            "essential": true,
            "environment": [
                {
                    "name": "DD_API_KEY",
                    "value": "<DD_API_KEY>"
                },
                {
                    "name": "DD_SITE",
                    "value": "datadoghq.com"
                },
                {
                    "name": "ECS_FARGATE",
                    "value": "true"
                },
                {
                    "name": "DD_RUNTIME_SECURITY_CONFIG_ENABLED",
                    "value": "true"
                },
                {
                    "name": "DD_RUNTIME_SECURITY_CONFIG_EBPFLESS_ENABLED",
                    "value": "true"
                }
            ],
            "healthCheck": {
                "command": [
                    "CMD-SHELL",
                    "/probe.sh"
                ],
                "interval": 30,
                "timeout": 5,
                "retries": 2,
                "startPeriod": 60
            }
        },
        {
            "name": "<YOUR_APP_NAME>",
            "image": "<YOUR_APP_IMAGE>",
            "entryPoint": [
                "/cws-instrumentation-volume/cws-instrumentation",
                "trace",
                "--",
                "<ENTRYPOINT>"
            ],
            "mountPoints": [
                {
                    "sourceVolume": "cws-instrumentation-volume",
                    "containerPath": "/cws-instrumentation-volume",
                    "readOnly": true
                }
            ],
            "linuxParameters": {
                "capabilities": {
                    "add": [
                        "SYS_PTRACE"
                    ]
                }
            },
            "dependsOn": [
                {
                    "containerName": "datadog-agent",
                    "condition": "HEALTHY"
                },
                {
                    "containerName": "cws-instrumentation-init",
                    "condition": "SUCCESS"
                }
            ]
        }
    ],
    "volumes": [
        {
            "name": "cws-instrumentation-volume"
        }
    ]
}
  1. JSON ファイルの以下の項目を更新します。

    • TASK_NAME
    • DD_API_KEY
    • DD_SITE
    • YOUR_APP_NAME
    • YOUR_APP_IMAGE
    • ENTRYPOINT

    以下のコマンドを使用して、ワークロードのエントリーポイントを見つけることができます。

    docker inspect <YOUR_APP_IMAGE> -f '{{json .Config.Entrypoint}}'
    

    または

    docker inspect <YOUR_APP_IMAGE> -f '{{json .Config.Cmd}}'
    

    : 環境変数 ECS_FARGATE はすでに “true” に設定されています。

  2. タスク定義に他のアプリケーションコンテナを追加します。インテグレーションメトリクスの収集の詳細については、ECS Fargate のインテグレーションセットアップを参照してください。

  3. 次のコマンドを実行して ECS タスク定義を登録します。

aws ecs register-task-definition --cli-input-json file://<PATH_TO_FILE>/datadog-agent-ecs-fargate.json

Datadog Cloud Security

  1. Datadog で、Cloud Security > Setup > Cloud Integrations > AWS に移動します。
  2. Amazon ECR をホストする AWS アカウントに Datadog Agentless scanner をデプロイして、Vulnerability Management を有効化します。

AWS Fargate ポッドからデータを収集するには、Agent をアプリケーションポッドのサイドカーとして実行し、ロールベースのアクセス制御 (RBAC) ルールを設定する必要があります。

Agent がサイドカーとして実行されている場合、同じポッド上のコンテナとのみ通信できます。監視するすべてのポッドに対して Agent を実行します。

RBAC ルールの設定

Agent をサイドカーとしてデプロイする前に、以下の Agent RBAC デプロイメント手順を使用します。

Agent をサイドカーとしてデプロイする

以下のマニフェストは、Workload Protection を有効にした Datadog Agent をサイドカーとしてアプリケーションをデプロイするために必要な最小構成を示します:

apiVersion: apps/v1
kind: Deployment
metadata:
 name: "<APPLICATION_NAME>"
 namespace: default
spec:
 replicas: 1
 selector:
   matchLabels:
     app: "<APPLICATION_NAME>"
 template:
   metadata:
     labels:
       app: "<APPLICATION_NAME>"
     name: "<POD_NAME>"
   spec:
     initContainers:
     - name: cws-instrumentation-init
       image: public.ecr.aws/datadog/cws-instrumentation:latest
       command:
         - "/cws-instrumentation"
         - "setup"
         - "--cws-volume-mount"
         - "/cws-instrumentation-volume"
       volumeMounts:
         - name: cws-instrumentation-volume
           mountPath: "/cws-instrumentation-volume"
       securityContext:
         runAsUser: 0
     containers:
     - name: "<YOUR_APP_NAME>"
       image: "<YOUR_APP_IMAGE>"
       command:
         - "/cws-instrumentation-volume/cws-instrumentation"
         - "trace"
         - "--"
         - "<ENTRYPOINT>"
       volumeMounts:
         - name: cws-instrumentation-volume
           mountPath: "/cws-instrumentation-volume"
           readOnly: true
     - name: datadog-agent
       image: public.ecr.aws/datadog/agent:latest
       env:
         - name: DD_API_KEY
           value: "<DD_API_KEY>"
         - name: DD_RUNTIME_SECURITY_CONFIG_ENABLED
           value: "true"
         - name: DD_RUNTIME_SECURITY_CONFIG_EBPFLESS_ENABLED
           value: "true"
         - name: DD_EKS_FARGATE
           value: "true"
         - name: DD_CLUSTER_NAME
           value: "<CLUSTER_NAME>"
         - name: DD_KUBERNETES_KUBELET_NODENAME
           valueFrom:
             fieldRef:
               apiVersion: v1
               fieldPath: spec.nodeName
     volumes:
       - name: cws-instrumentation-volume
     serviceAccountName: datadog-agent
     shareProcessNamespace: true

Agent が Cloud Security にイベントを送信していることを確認する

AWS Fargate ECS または EKS で Cloud Security を有効化すると、Agent はデフォルト ルール セットが正常にデプロイされたことを確認するための agent event を Datadog に送信します。agent event を表示するには、Datadog の Agent Events ページに移動し、@agent.rule_id:ruleset_loaded を検索します。

手動で AWS Fargate のセキュリティ シグナルをトリガーして、Agent が Cloud Security にイベントを送信していることを検証することもできます。

タスク定義で、“workload” コンテナを以下のように置き換えます。

            "name": "cws-signal-test",
            "image": "ubuntu:latest",
            "entryPoint": [
                "/cws-instrumentation-volume/cws-instrumentation",
                "trace",
                "--verbose",
                "--",
                "/usr/bin/bash",
                "-c",
                "apt update;apt install -y curl; while true; do curl https://google.com; sleep 5; done"
            ],

App and API Protection

前提条件

  • Datadog Agent が、アプリケーションのオペレーティングシステムやコンテナ、クラウド、仮想環境にインストールされ構成されている
  • アプリケーションまたはサービスで Datadog APM が構成されている
パフォーマンスと信頼性に関するさらなるインサイトのために、Datadog は App and API Protection と併用して Application Performance Monitoring を有効化することを推奨します。

インストール

ソフトウェア構成分析 (SCA)

Software Composition Analysis (SCA) は Fargate で動作します。 従来のホストで実行されるアプリケーション向けのインストール手順 に従ってください。

脅威の検出と保護

ステップバイステップの手順については、以下の記事を参照してください。

コードセキュリティ

ステップバイステップの手順については、以下の記事を参照してください。

クラウド SIEM

前提条件

インストール

ステップバイステップの手順については、Cloud SIEM のための AWS 構成ガイドを参照してください。

AWS CloudTrail のログを有効にする

Enable AWS CloudTrail logging so that logs are sent to a S3 bucket. If you already have this setup, skip to Send AWS CloudTrail logs to Datadog.

  1. Click Create trail on the CloudTrail dashboard.
  2. Enter a name for your trail.
  3. Create a new S3 bucket or use an existing S3 bucket to store the CloudTrail logs.
  4. Create a new AWS KMS key or use an existing AWS KMS key, then click Next.
  5. Leave the event type with the default management read and write events, or choose additional event types you want to send to Datadog, then click Next.
  6. Review and click Create trail.

AWS CloudTrail のログを Datadog に送信する

Set up a trigger on your Datadog Forwarder Lambda function to send CloudTrail logs stored in the S3 bucket to Datadog for monitoring.

  1. Go to the Datadog Forwarder Lambda that was created during the AWS integration set up.
  2. Click Add trigger.
  3. Select S3 for the trigger.
  4. Select the S3 bucket you are using to collect AWS CloudTrail logs.
  5. For Event type, select All object create events.
  6. Click Add.
  7. See CloudTrail logs in Datadog’s Log Explorer.

See Log Explorer for more information on how to search and filter, group, and visualize your logs.

その他の参考資料