1

我通过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 planterraform 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

https://github.com/hashicorp/terraform/issues/8669

4

0 回答 0