Datadog 보안용 AWS Fargate 구성 가이드

본 가이드는 AWS Fargate에서 Cloud Security, Software Composition Analysis(SCA), 위협 탐지 및 보호(AAP), Cloud SIEM를 구성하는 방법을 안내합니다.

AWS Fargate에서 Cloud Security, AAP, Cloud SIEM가 구성되는 방식을 보여주는 플로우 차트

AWS Fargate의 풀 스택 커버리지

Datadog Security는 AWS Fargate의 다중 계층의 가시성을 제공합니다. 다음 테이블처럼 제품을 서로 조합해 사용하면 풀 스택 커버리지를 확보할 수 있습니다.

Fargate 에셋

에셋Observability취약성 및 잘못된 설정 수정위협 탐지 및 대응
Fargate 애플리케이션Application Performance MonitoringSoftware Composition Analysis(SCA) 및 Code SecurityAAP - 위협 탐지 및 보호
Fargate 인프라스트럭처Infrastructure MonitoringCloud SecurityWorkload Protection

Fargate 관련 소스

에셋Observability취약성 및 잘못된 설정 수정위협 탐지 및 대응
AWS IAM 역할 및 정책Log ManagementCloud SecurityCloud SIEM
AWS 데이터베이스Log ManagementCloud SecurityCloud SIEM
AWS S3 버킷Log ManagementCloud SecurityCloud SIEM

클라우드 보안

사전 필수 조건

  • Datadog AWS 통합은 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 Console

  1. AWS Management Console에 로그인합니다.
  2. ECS 섹션으로 이동합니다.
  3. 왼쪽 메뉴에서 Task Definitions를 선택한 다음 Create new Task Definition with JSON를 선택합니다. 또는 기존 Fargate Task Definition을 선택합니다.
  4. 새 작업 정의를 생성하려면 JSON 정의 또는 AWS CLI 메서드를 사용하세요.
  5. 생성을 클릭하여 작업 정의를 생성합니다.

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 스캐너를 배포하여 Vulnerability Management를 사용 설정합니다.

AWS Fargate 포드에서 데이터를 수집하려면, 반드시 애플리케이션 포드의 사이드카로 Agent를 실행하고 Role-Based Access Control(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 이벤트를 Datadog으로 전송하여 기본 규칙 세트가 배포되었는지 확인합니다. Agent 이벤트를 확인하려면 Datadog에서 Agent Events 페이지로 이동하여 @agent.rule_id:ruleset_loaded를 검색합니다.

AWS Fargate 보안 신호를 수동 트리거하여 Agent가 이벤트를 Cloud Security로 전송하는지 확인할 수도 있습니다.

작업 정의에서 “워크로드” 컨테이너를 다음으로 변경합니다.

            "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은 앱 및 API Protection으로 Application Performance Monitoring을 활성화할 것을 권장합니다.

설치

소프트웨어 구성 분석(SCA)

Software Composition Analysis(SCA)은 Fargate에서 작동합니다. 기존 호스트에서 실행되는 애플리케이션의 설치 단계를 따르세요.

위협 탐지 및 보호

단계별 지침을 보려면 다음 문서를 참조하세요.

Code Security

단계별 지침을 보려면 다음 문서를 참조하세요.

Cloud SIEM

사전 필수 조건

  • 로그 수집은 소스에서 로그를 수집하도록 설정됩니다.

설치

단계별 지침은 AWS Cloud SIEM 구성 가이드를 참조하세요.

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.

Datadog에 AWS CloudTrail 로그 전송

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.

참고 자료