Hi ,
I am creating an infrastructure project using terraform , here I have a ECS cluster which has three services running.
All of the three service 's task definition contain environments which have spring variables.
Now to create the services I am calling underlying modules , and have created the container definitions inside my locals file.
My requirement is that instead of using three different local variables for container definitions I want to use just one which conditions defined as to which parameter to use for which service.
But the problem that I am facing is that how do I setup the conditions in the variables i.e. how will I assign the values dynamically to the varibles on the basis which module is calling it.
Code snippets to make it clearer -
my locals file -
locals {
cd_service = {
“SPRING_PROFILES_ACTIVE” = “${var.environment},aws”
“java.security.egd” = “file:///dev/urandom”
“JAVA_OPTS” = "-Xdebug -Xrunjdwp:transport=dt_socket,address=8009,server=y,suspend=n
}
cd_xyz = {
“SPRING_PROFILES_ACTIVE” = “${var.environment},aws”
“pv.ui.websocket.prefix” = “/ws”
“server.port” = 8080
}
}
My services file which I use to create the service through modules calls-
module “service” {
source = xxxxx
tags = var.tags
container_environment = local.cd_service
}
module “xyz” {
source = xxxxx
tags = var.tags
container_environment = local.cd_xyz
}
Please help me with is as its a blocker , thanks in advance would really appreciate a quick response