Hi,
I've been trying to use 'data template_file' declarations in the same way the 'resource template_file' documentation describes and I've run into a difference. I was wondering if anyone had an explanation / workaround?
For example, with this block:
[resource|data] "template_file" "role" {
template = "${file("${path.module}/mongodb.yml.tpl")}"
count = "${var.num_nodes}"
vars {
environment = "${var.account_name}"
group = "Infrastructure"
primary = "${lookup(var.primary_status, count.index)}"
}
}
If this is a resource declaration (basically the "Using Templates with Count" example) then this works exactly as described (albeit with warnings):
$ terraform plan -target module.mongodb
There are warnings and/or errors related to your configuration. Please
fix these before continuing.
Warnings:
* template_file.role #2: using template_file as a resource is deprecated; consider using the data source instead
* template_file.role #0: using template_file as a resource is deprecated; consider using the data source instead
* template_file.role #1: using template_file as a resource is deprecated; consider using the data source instead
<SNIP>
If this is a "data" block then the following happens when I plan:
$ terraform plan -target module.mongodb
There are warnings and/or errors related to your configuration. Please
fix these before continuing.
Errors:
* data.template_file.role #0: : invalid or unknown key: count
* data.template_file.role #1: : invalid or unknown key: count
* data.template_file.role #2: : invalid or unknown key: count
<SNIP>
exit status 1
Is this expected? Can we use counts with 'data template_file' elements the same way we did with resources?
Thanks,
Matt