@@ -63,25 +63,40 @@ locals {
6363 }
6464
6565 container_definitions_map = {
66- for svc , task_def in local . task_definitions_with_roles : svc =>
67- (svc == "api-dev" ?
66+ for svc , task_def in local . task_definitions_with_roles : svc => flatten ([
6867 [
6968 {
70- name = "api-dev"
71- image = " ${local. ecr_repo_urls ["dev"]}:placeholder"
69+ name = svc
70+ image = svc == " api-dev " ? " ${ local . ecr_repo_urls [" dev" ]} :placeholder" : task_def.container_image
7271 cpu = task_def.cpu
7372 memory = contains (keys (task_def), " memory" ) ? task_def.memory : null
73+ memoryReservation = lookup (task_def, " memoryReservation" , null )
7474 essential = true
75- command = [
75+ command = svc == " api-dev " ? tolist ( [
7676 " java" , " -javaagent:/dd-java-agent.jar" ,
7777 " -Ddd.logs.injection=true" , " -Ddd.runtime-metrics.enabled=true" ,
7878 " -Ddd.service=eatda-api" , " -Ddd.env=dev" , " -Ddd.version=v1" ,
7979 " -Ddd.agent.host=127.0.0.1" ,
8080 " -Dspring.profiles.active=dev" , " -jar" , " /api.jar"
81+ ]) : tolist ([])
82+ portMappings = [
83+ for m in lookup (task_def, " port_mappings" , []) :
84+ { containerPort = m.container_port, hostPort = m.host_port, protocol = m.protocol }
85+ ]
86+ environment = [for k , v in lookup (task_def, " environment" , {}) : { name = k, value = v }]
87+ secrets = [for s in lookup (task_def, " secrets" , []) : { name = s.name, valueFrom = s.valueFrom }]
88+ mountPoints = [
89+ for vol in lookup (task_def, " volumes" , []) : {
90+ sourceVolume = vol.name
91+ containerPath = (
92+ (svc == "mysql-dev" && vol. name == "dev-mysql-volume") ? "/var/lib/mysql" : vol. containerPath
93+ )
94+ readOnly = false
95+ }
8196 ]
82- portMappings = [{ containerPort = 8080, hostPort = 0, protocol = "tcp" }]
83- mountPoints = [{ sourceVolume = "dev-api-volume", containerPath = "/logs", readOnly = false }]
84- },
97+ }
98+ ],
99+ svc == "api-dev" ? [
85100 {
86101 name = "datadog-agent"
87102 image = "public. ecr . aws /datadog/agent:latest"
@@ -102,32 +117,11 @@ locals {
102117 { sourceVolume = "proc", containerPath = "/host/proc", readOnly = true },
103118 { sourceVolume = "cgroup", containerPath = "/host/sys/fs/cgroup", readOnly = true }
104119 ]
120+ command = tolist([])
121+ portMappings = []
105122 }
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- ])
123+ ] : []
124+ ])
131125 }
132126
133127 final_ecs_definitions_for_module = {
0 commit comments