Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depends_on broken for Data template_file #9086

Closed
stongo opened this issue Sep 27, 2016 · 5 comments
Closed

depends_on broken for Data template_file #9086

stongo opened this issue Sep 27, 2016 · 5 comments

Comments

@stongo
Copy link

stongo commented Sep 27, 2016

Terraform Version

v0.7.4

Affected Resource(s)

  • data template_file

Terraform Configuration Files

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")}"
  }
}

Debug Output

https://gist.github.com/stongo/1c4c16773d8b8189215c3fd48054c729

Expected Behavior

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.

Actual Behavior

The template data is updated before null_resource.discovery_token executes

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
@mluedke
Copy link

mluedke commented Oct 18, 2016

I am having the same issue on v0.7.7.

@mitchellh
Copy link
Contributor

I'm unable to reproduce this. The ordering happens properly for me. If you have any additional reproduction info please let me know!

@lehins
Copy link

lehins commented Dec 28, 2016

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

@arehmandev
Copy link
Contributor

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.

@ghost
Copy link

ghost commented Apr 18, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants