Ignore_changes life cycle for the attributes inside a template_file

Hi There,

Any suggestion on how to handle ignore_changes for the attributes inside a template_file ?

In the below, i have an use case where I wanted the task definition to be untouched if the tag values changes.

resource “template_file” “credit_task_definition_template” {
template = file("${path.module}/templates/ecsTaskDefinition.json.tpl")

vars = {
image = “{var.image}" region = “{var.region}”
tag= “{var.tag}” containerName = “{var.container_name}”
containerPort = “{var.container_port}” hostPort = “{var.container_port}”
memory = “{var.memory}” networkMode = "{var.network_mode}”
group_name = “${var.task_name}”

}

lifecycle {
ignore_changes = [“vars.tag”]
}
}

resource “aws_ecs_task_definition” “credit_task_definition” {
container_definitions = template_file.credit_task_definition_template.rendered

requires_compatibilities = “{var.capabilities}" network_mode = “{var.network_mode}”
cpu = “{var.cpu}” memory = “{var.memory}”
task_role_arn = “{var.task_role}” execution_role_arn = "{var.execution_role}”
family = “${var.task_name}”

}

and the template file is

[
{
“name”: "{containerName}", "image": "{image}:{product_version}", "portMappings": [ { "containerPort": {containerPort},
“hostPort”: {hostPort} } ], "memory": {memory},
“networkMode”: “{networkMode}", "logConfiguration": { "logDriver": "awslogs", "secretOptions": null, "options": { "awslogs-group": "/ecs/{group_name}”,
“awslogs-region”: “${region}”,
“awslogs-create-group”: “true”,
“awslogs-stream-prefix”: “ecs”
}
},
“environment”: [
{
“name”: “ENV”,
“value”: “dev”
}
]
}
]