Change nested maps values

Hi there !

I have this local map variable
(some AWS ECS tasks definition configurations from .JSON files)

tasks = {
  "service1" = {
      task_definition = {
        "cpu": 128,
        "environment": [
            {
            "name": "DB_HOST",
            "value": "X"
            }
        ],
        "essential": true,
        "healthCheck": {}
        }
  }
  "service2" = {
    "task_definition" = ...
  }
}

I want to change DB_HOST value based on other module output :

  • worth noting it won’t be there on each service

Something like that

tasks.x.task_definition.environment[x].value = module.example.db_host
-> DB_HOST = module.example.db_host

didn’t manage to do it when looping through the map keys…

Thanks in advance !