我通过terraform部署ecs服务,并通过template_file
数据源定义任务定义。
data "template_file" "task_definition" {
template = "${file("${"${path.module}/task-definition.json"}")}"
vars {
region = "${var.region}"
consul_address = "${aws_instance.consul.private_ip}"
}
}
resource "aws_ecs_task_definition" "service" {
family = "service"
container_definitions = "${data.template_file.task_definition.rendered}"
volume {
name = "service-storage"
host_path = "/ecs/service-storage"
}
placement_constraints {
type = "memberOf"
expression = "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]"
}
}
但是当我在更改任务定义模板后运行terraform plan
或terraform apply
时,它只显示我
task_definition: "arn:aws:ecs:xxxx:xxxx:task-definition/xxxx-task-definition:15" => "${aws_ecs_task_definition.service.arn}"
但是没有向我展示任务定义的最终内容。
那么有没有办法显示最新的任务定义(所有变量都替换为实际值)?
似乎有人已经报告了这个问题。
https://github.com/terraform-providers/terraform-provider-template/issues/4