Datadog Security を使用するための AWS Fargate 構成ガイド
このガイドでは、AWS Fargate 上での Cloud Security Management (CSM)、Application Security Management (ASM)、Cloud SIEM の構成について説明します。
Datadog Security は、AWS Fargate を多層的に可視化します。次の表に示すように、これらの製品を互いに組み合わせて使用することで、あらゆる要素をカバーできます。
アセット | 観測可能性 | 脆弱性と誤構成の修復 | 脅威の検出と対応 |
---|
|
Fargate アプリケーション | Application Performance Monitoring | Application Security Management | Application Security Management |
Fargate インフラストラクチャー | Infrastructure Monitoring | 未対応 | CSM Threats |
アセット | 観測可能性 | 脆弱性と誤構成の修復 | 脅威の検出と対応 |
---|
AWS IAM ロールとポリシー | Log Management | Cloud Security Management | Cloud SIEM |
AWS データベース | Log Management | Cloud Security Management | Cloud SIEM |
AWS S3 バケット | Log Management | Cloud Security Management | Cloud SIEM |
- AWS アカウントに対して Datadog AWS インテグレーションがインストールされ、構成されていること。
- AWS マネジメントコンソールへのアクセス権
- AWS Fargate ECS または EKS のワークロード
パフォーマンスと信頼性に関するさらなるインサイトを得るために、Datadog は、Infrastructure Monitoring を Cloud Security Management と共に有効にすることを推奨しています。
cws-instrumentation-init
: public.ecr.aws/datadog/cws-instrumentation:latest
datadog-agent
: public.ecr.aws/datadog/agent:latest
- AWS マネジメントコンソールにサインインします。
- ECS セクションに移動します。
- 左のメニューから Task Definitions を選択し、Create new Task Definition with JSON を選択します。または、既存の Fargate タスク定義を選択します。
- 新しいタスク定義を作成するには、JSON 定義を使用するか、AWS CLI メソッドを使用します。
- Create をクリックしてタスク定義を作成します。
- 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
AWS Fargate ポッドからデータを収集するには、Agent をアプリケーションポッドのサイドカーとして実行し、ロールベースのアクセス制御 (RBAC) ルールを設定する必要があります。
Agent がサイドカーとして実行されている場合、同じポッド上のコンテナとのみ通信できます。監視するすべてのポッドに対して Agent を実行します。
Agent をサイドカーとしてデプロイする前に、以下の Agent RBAC デプロイメント手順を使用します。
次のマニフェストは、CSM Threats を有効にし、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
AWS Fargate ECS または EKS で CSM を有効にすると、Agent から Datadog にログが送信され、デフォルトのルールセットが正常にデプロイされたことが確認されます。ログを確認するには、Datadog の Logs ページに移動し、@agent.rule_id:ruleset_loaded
を検索します。
また、AWS Fargate セキュリティシグナルを手動でトリガーすることで、Agent が CSM にイベントを送信していることを確認することもできます。
タスク定義で、“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"
],
- Datadog Agent が、アプリケーションのオペレーティングシステムやコンテナ、クラウド、仮想環境にインストールされ構成されている
- アプリケーションまたはサービスで Datadog APM が構成されている
パフォーマンスと信頼性に関するさらなるインサイトを得るために、Datadog は、Application Performance Monitoring を Application Security Management と共に有効にすることを推奨しています。
ステップバイステップの手順については、以下の記事を参照してください。
ステップバイステップの手順については、以下の記事を参照してください。
ステップバイステップの手順については、Cloud SIEM のための AWS 構成ガイドを参照してください。
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.
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.