The template_file
provider is both deprecated, and not available for ARM machines. We are replacing it everywhere with calls to the templatefile
function. However, in some places we use template_file
with count
and reference the resources later, and we can’t find a straightforward way to do that with templatefile
.
Example:
data "template_file" "node_json" {
count = var.brokers
vars = {
...
}
}
and then
module "..." {
nodes = data.template_file.node_json.*.rendered
}
or
resource "..." {
count = var.brokers
data = element( data.template_file.node_json.*.rendered, count.index)
I have found a way to do something similar using instead the null_resource
:
data "null_data_source" "node_json" {
count = var.brokers
inputs = {
node = templatefile("${path.module}/kitchen/nodes/broker.json", {...})
}
}
and then
module "..." {
nodes = data.null_data_source.node_json.*.outputs.node
}
This works fine, but I get a warning:
│ Warning: Deprecated Resource
│
│ The null_data_source was historically used to construct intermediate values to re-use elsewhere in configuration, the same can now be achieved using locals
As far as I know, I can’t use count
with locals…
Any suggestions will be welcome. TF version 1.2.7, by the way.
Thanks!