如何在运行`terraform plan`或`apply`时显示任务定义模板内容?

时间:2018-01-08 06:41:18

标签: amazon-web-services terraform terraform-template-file

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

0 个答案:

没有答案