v0.7.4
resource "null_resource" "discovery_token" {
provisioner "local-exec" {
command = "curl https://discovery.etcd.io/new?size=${var.node_count} > ${path.module}/.token"
}
}
data "template_file" "cloud_config" {
depends_on = ["null_resource.discovery_token"]
template = "${file("${path.module}/templates/cloud-config.yaml")}"
vars {
discovery_token = "${file("${path.module}/.token")}"
}
}
https://gist.github.com/stongo/1c4c16773d8b8189215c3fd48054c729
The depends_on directive should still be obeyed or else panic if it's not allowed. In this case the null_resource.discovery_token should complete before data template is updated.
If not allowed, please restore it's functionality as templating becomes very limited without any control structure.
The template data is updated before null_resource.discovery_token executes
Please list the steps required to reproduce the issue, for example:
terraform applyI am having the same issue on v0.7.7.
I'm unable to reproduce this. The ordering happens properly for me. If you have any additional reproduction info please let me know!
The actual issue is not in depends_on, but rather in the file interpolation function. It reads the file during validation, not during rendering the template. Just for anybody looking here is a related ticket #8406
Just encountered this one too. Heres to recreate:
resource "null_resource" "hello" {
provisioner "local-exec" {
command = "bash hello > ${path.module}/hello.txt"
}
}
data "template_file" "init" {
depends_on = ["null_resource.hello"]
template = "${file("${path.module}/hello.txt")}"
}
The data.template_file will fail as it will say ${path.module}/hello.txt doesn't exist despite the depends_on being stated.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
The actual issue is not in
depends_on, but rather in thefileinterpolation function. It reads the file during validation, not during rendering the template. Just for anybody looking here is a related ticket #8406