Datadog Security を使用するための AWS Fargate 構成ガイド
このガイドでは、AWS Fargate 上で Cloud Security、Software Composition Analysis (SCA)、Threat Detection and Protection (AAP)、および Cloud SIEM を構成する手順を説明します。
AWS Fargate をフルスタックでカバー
Datadog Security は、AWS Fargate を多層的に可視化します。次の表に示すように、これらの製品を互いに組み合わせて使用することで、あらゆる要素をカバーできます。
Fargate アセット
アセット | 可観測性 | 脆弱性と誤構成の是正 | 脅威検知とレスポンス | |
Fargate アプリケーション | Application Performance Monitoring | Software Composition Analysis (SCA) and Code Security | AAP - Threat Detection and Protection |
Fargate インフラストラクチャー | Infrastructure Monitoring | Cloud Security | Workload Protection |
Fargate 関連リソース
アセット | 可観測性 | 脆弱性と誤構成の是正 | 脅威検知とレスポンス | AWS IAM のロールとポリシー | Log Management | Cloud Security | Cloud SIEM |
AWS データベース | Log Management | Cloud Security | Cloud SIEM |
AWS S3 バケット | Log Management | Cloud Security | Cloud 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 コンソール
- AWS マネジメントコンソールにサインインします。
- ECS セクションに移動します。
- 左のメニューから Task Definitions を選択し、Create new Task Definition with JSON を選択します。または、既存の Fargate タスク定義を選択します。
- 新しいタスク定義を作成するには、JSON 定義を使用するか、AWS CLI メソッドを使用します。
- Create をクリックしてタスク定義を作成します。
AWS CLI
- 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"
}
]
}
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” に設定されています。
タスク定義に他のアプリケーションコンテナを追加します。インテグレーションメトリクスの収集の詳細については、ECS Fargate のインテグレーションセットアップを参照してください。
次のコマンドを実行して ECS タスク定義を登録します。
aws ecs register-task-definition --cli-input-json file://<PATH_TO_FILE>/datadog-agent-ecs-fargate.json
Datadog Cloud Security
- Datadog で、Cloud Security > Setup > Cloud Integrations > AWS に移動します。
- 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.
- Click Create trail on the CloudTrail dashboard.
- Enter a name for your trail.
- Create a new S3 bucket or use an existing S3 bucket to store the CloudTrail logs.
- Create a new AWS KMS key or use an existing AWS KMS key, then click Next.
- 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.
- 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.
- Go to the Datadog Forwarder Lambda that was created during the AWS integration set up.
- Click Add trigger.
- Select S3 for the trigger.
- Select the S3 bucket you are using to collect AWS CloudTrail logs.
- For Event type, select All object create events.
- Click Add.
- 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.
その他の参考資料