forked from riboseinc/terraform-aws-ecs-datadog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ecs_datadog.tf
98 lines (91 loc) · 2.02 KB
/
ecs_datadog.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
resource "aws_ecs_task_definition" "datadog" {
family = "${var.env}-${var.identifier}-task"
task_role_arn = aws_iam_role.ecs-datadog-role.arn
container_definitions = <<EOF
[
{
"name": "${var.env}-${var.identifier}",
"image": "datadog/agent:latest",
"cpu": 10,
"memory": 256,
"essential": true,
"portMappings": [
{
"containerPort": 8126,
"hostPort": 8126,
"protocol": "tcp"
}
],
"environment": [
{
"name" : "DD_API_KEY",
"value" : "${var.datadog-api-key}"
},
{
"name" : "DD_SITE",
"value" : "datadoghq.com"
},
{
"name" : "DD_APM_ENABLED",
"value" : "${var.dd_apm_enabled}"
},
{
"name": "DD_LOGS_ENABLED",
"value": "true"
},
{
"name": "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL",
"value": "true"
},
{
"name": "SD_BACKEND",
"value": "docker"
},
{
"name" : "DD_APM_NON_LOCAL_TRAFFIC",
"value" : "${var.dd_apm_non_local_traffic}"
},
{
"name" : "DD_TAGS",
"value" : "env:${var.env}"
}
],
"mountPoints": [{
"sourceVolume": "docker-sock",
"containerPath": "/var/run/docker.sock",
"readOnly": true
},{
"sourceVolume": "proc",
"containerPath": "/host/proc",
"readOnly": true
},{
"sourceVolume": "cgroup",
"containerPath": "/host/sys/fs/cgroup",
"readOnly": true
}]
}
]
EOF
volume {
name = "docker-sock"
host_path = "/var/run/docker.sock"
}
volume {
name = "proc"
host_path = "/proc/"
}
volume {
name = "cgroup"
host_path = "/sys/fs/cgroup/"
}
}
resource "aws_ecs_service" "datadog" {
name = "${var.env}-${var.identifier}-datadog-ecs-service"
cluster = var.ecs-cluster-id
task_definition = aws_ecs_task_definition.datadog.arn
# This allows running once for every instance
scheduling_strategy = "DAEMON"
lifecycle {
ignore_changes = [task_definition]
}
}