Damn. It was unnessessary difficult to parametrize environment variables that are passed down to ECS task definition. But thanks to https://github.com/Eiara/terraform_container_definitions I managed to do it.