Terraform: 0.7.1 regression: template_file: unknown variable accessed: ulimit

Created on 24 Aug 2016  ยท  9Comments  ยท  Source: hashicorp/terraform

Today I tried to upgrade from the latest 0.6 release to 0.7.1 and there seems to be a bug I can't get around.

I am using a template_file resource (now change to data instead of resource) in this file I have the following line:

  - echo "* soft nofile ${ulimit}" >> /etc/security/limits.conf

And of-course I pass the argument to the template file:

vars {
      ulimit = "40000"
    }

When I run an apply I get the following error:

 data.template_file.cloud-init: failed to render : 98:28: unknown variable accessed: ulimit

This all works perfectly fine in 0.6 but not in 0.7.1

Here is a link to my debug output: https://gist.github.com/jasonf20/d836763cec4e194458534e7f6c6d1148

EDIT: See my update below the issue is resolved for me but I have no idea why. Feel free to close this issue or use it to chat about the cause of this error message.

bug providetemplate

Most helpful comment

This is fixed in 0.8!

All 9 comments

Update: This does not fail when trying to create a small template file example. It only fails when this is part of a more complicated system. In my case the template file is inside a module and I'm using this module from another tf file. I'm not sure exactly what the conditions to duplicate are :(

Hi @jasonf20, I had a similar issue yesterday, but the cause was that I had an error like the following:

variable foo {
  default = "${bar}" # should be ${var.bar}
}

vars {
      foo = "${var.foo}"
}

Yet, terraform was complaining about unknown variable accessed: foo instead of unknown variable accessed: bar.

The difference with your issue is that you have no interpolation when defining ulimit.
Is that really the case?

@pdecat Thanks for the comment. I don't think that is really the issue for me since:

  1. It works for me in 0.6.16
  2. I don't have interpolation in the definition of ulimit (I did, but I removed it to be sure it's not the issue)

Update: The issue seemed to resolve itself for me. Perhaps something completely unrelated that I changed fixed this. However, even if this is the case, the error message I got is really bad and did not lead me to the issue at hand. Therefore there is still something that needs fixing here.

I hit a similar problem when using "count" interpolation. For example when I try to reference ${myvar} from a rendered template like so:

data "template_file" "kube-apiserver" {
  count = "${var.nodes}"
  template = "${file("mytemplate.tpl")}"
  vars {
    myvar = "value"
  }
}

mytemplate.tpl:

value: ${myvar}

My workaround was to slightly re-factor so that I could remove the count interpolation.

I confirm that template_file in module with count interpolation throws this exception.

I'm getting errors too. Specifically when I have one interpolated string, which is used inside another.

This is fixed in 0.8!

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rkulagowski picture rkulagowski  ยท  3Comments

ronnix picture ronnix  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

zeninfinity picture zeninfinity  ยท  3Comments

shanmugakarna picture shanmugakarna  ยท  3Comments