template_file
renders a template from a file.
Use it with a file
or inline
. E.g.
file
1 2 3 4 5 6 |
data "template_file" "ec2_policy" { template = "${file("policies/ec2_policy.json.tftemplate")}" vars { ip_address - ${aws_instance.my_instances.private_ip}" } |
file
refers to a file path in the current directory.
and ip_address
is set to a value which can be read in the template using ${ip_address}
.
1 2 3 4 5 6 7 |
data "template_file" "init" { template = "${file("${path.module}/init.tpl")}" vars { consul_address = "${aws_instance.consul.private_ip}" } } |
Note: see also Terraform: Data Sources
and https://www.terraform.io/docs/providers/template/d/file.html#