@@ -63,57 +63,71 @@ locals {
6363 }
6464
6565 container_definitions_map = {
66- for svc , def in local . task_definitions_with_roles : svc => [
67- {
68- name = svc
69- image = svc == " api-dev" ? " ${ local . ecr_repo_urls [" dev" ]} :placeholder" : def.container_image
70- cpu = def.cpu
71- memory = def.memory
72- essential = true
73- stopTimeout = lookup (def, " stop_timeout" , 30 )
74- command = svc == " api-dev" ? [
75- " java" ,
76- " -javaagent:/dd-java-agent.jar" ,
77- " -Ddd.logs.injection=true" ,
78- " -Ddd.runtime-metrics.enabled=true" ,
79- " -Ddd.service=eatda-api" ,
80- " -Ddd.env=dev" ,
81- " -Ddd.version=v1" ,
82- " -Ddd.agent.host=10.0.7.245" ,
83- " -Dspring.profiles.active=dev" ,
84- " -jar" ,
85- " /api.jar"
86- ] : null
87- portMappings = [
88- for m in lookup (def, " port_mappings" , []) : {
89- name = " ${ svc } -${ m . container_port } -${ m . protocol } "
90- containerPort = m.container_port
91- hostPort = m.host_port
92- protocol = m.protocol
93- }
94- ]
95- environment = [for k , v in lookup (def, " environment" , {}) : { name = k, value = v }]
96- secrets = svc == " datadog-agent-task" ? [
97- { name = " DD_API_KEY" , valueFrom = " /dev/DD_API_KEY" }
98- ] : (svc == " mysql-dev" ? [
99- { name = " MYSQL_USER" , valueFrom = " /dev/MYSQL_USER_NAME" },
100- { name = " MYSQL_ROOT_PASSWORD" , valueFrom = " /dev/MYSQL_ROOT_PASSWORD" },
101- { name = " MYSQL_PASSWORD" , valueFrom = " /dev/MYSQL_PASSWORD" }
102- ] : [
103- for s in lookup (def, " secrets" , []) : {
104- name = s.name
105- valueFrom = s.valueFrom
106- }
107- ])
108- mountPoints = [
109- for vol in lookup (def, " volumes" , []) : {
110- sourceVolume = vol . name
111- containerPath = vol . containerPath
112- readOnly = vol . readOnly
113- }
114- ]
115- }
116- ]
66+ for svc , task_def in local . task_definitions_with_roles : svc =>
67+ (svc == "api-dev" ?
68+ [
69+ {
70+ name = "api-dev"
71+ image = "${local. ecr_repo_urls ["dev"]}:placeholder"
72+ cpu = task_def. cpu
73+ memory = contains(keys(task_def), "memory") ? task_def. memory : null
74+ essential = true
75+ command = [
76+ "java", "-javaagent:/dd-java-agent. jar ",
77+ "-Ddd. logs . injection =true", "-Ddd. runtime-metrics . enabled =true",
78+ "-Ddd. service =eatda-api", "-Ddd. env =dev", "-Ddd. version =v1",
79+ "-Ddd. agent . host =127. 0 . 0 . 1 ",
80+ "-Dspring. profiles . active =dev", "-jar", "/api. jar "
81+ ]
82+ portMappings = [{ containerPort = 8080, hostPort = 0, protocol = "tcp" }]
83+ mountPoints = [{ sourceVolume = "dev-api-volume", containerPath = "/logs", readOnly = false }]
84+ },
85+ {
86+ name = "datadog-agent"
87+ image = "public. ecr . aws /datadog/agent:latest"
88+ cpu = 256
89+ memory = 128
90+ essential = true
91+ environment = [
92+ { name = "DD_SITE", value = "us5. datadoghq . com " },
93+ { name = "DD_PROCESS_AGENT_ENABLED", value = "true" },
94+ { name = "DD_APM_ENABLED", value = "true" },
95+ { name = "DD_LOGS_ENABLED", value = "true" },
96+ { name = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL", value = "true" },
97+ { name = "DD_DOGSTATSD_NON_LOCAL_TRAFFIC", value = "false" },
98+ ]
99+ secrets = [{ name = "DD_API_KEY", valueFrom = "/dev/DD_API_KEY" }]
100+ mountPoints = [
101+ { sourceVolume = "docker_sock", containerPath = "/var/run/docker. sock ", readOnly = true },
102+ { sourceVolume = "proc", containerPath = "/host/proc", readOnly = true },
103+ { sourceVolume = "cgroup", containerPath = "/host/sys/fs/cgroup", readOnly = true }
104+ ]
105+ }
106+ ]
107+ :
108+ [
109+ {
110+ name = svc
111+ image = task_def. container_image
112+ cpu = task_def. cpu
113+ memory = task_def. memory
114+ essential = true
115+ portMappings = [
116+ for m in lookup(task_def, "port_mappings", []) :
117+ { containerPort = m.container_port, hostPort = m.host_port, protocol = m.protocol }
118+ ]
119+ environment = [for k , v in lookup (task_def, " environment" , {}) : { name = k, value = v }]
120+ secrets = [for s in lookup (task_def, " secrets" , []) : { name = s.name, valueFrom = s.valueFrom }]
121+ mountPoints = [
122+ for vol in lookup (task_def, " volumes" , []) : {
123+ sourceVolume = vol.name
124+ containerPath = (svc == " mysql-dev" && vol.name == " dev-mysql-volume" ) ? " /var/lib/mysql" :
125+ vol.containerPath
126+ readOnly = false
127+ }
128+ ]
129+ }
130+ ])
117131 }
118132
119133 final_ecs_definitions_for_module = {
0 commit comments