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

terraform: disallow simple variables ("foo") #9698

Merged
merged 1 commit into from
Nov 8, 2016
Merged

Conversation

mitchellh
Copy link
Contributor

Fixes #5338 (and I'm sure many others)

There is no use case for "simple" variables in Terraform at all so
anytime one is found it should be an error.

There is a huge backwards incompatibility here that was not supposed
to be by design but I'm sure a lot of people are relying on: in the
template_file datasource, this bug allowed you to not escape your
interpolations and have the work. For example:

data "template_file" "foo" {
  template = "${a}"
  vars { a = 12 }
}

The above would work, but it shouldn't. The template should have to be
"$${a}" (to escape the interpolation).

Because of this BC, I recommend holding this until Terraform 0.8.0 and
documenting it carefully. As part of this PR, I've added some special
error message notes.

Fixes #5338 (and I'm sure many others)

There is no use case for "simple" variables in Terraform at all so
anytime one is found it should be an error.

There is a _huge_ backwards incompatibility here that was not supposed
to be by design but I'm sure a lot of people are relying on: in the
`template_file` datasource, this bug allowed you to not escape your
interpolations and have the work. For example:

```
data "template_file" "foo" {
  template = "${a}"
  vars { a = 12 }
}
```

The above would work, but it shouldn't. The template should have to be
`"$${a}"` (to escape the interpolation).

Because of this BC, I recommend holding this until Terraform 0.8.0 and
documenting it carefully. As part of this PR, I've added some special
error message notes.
@mitchellh mitchellh added this to the Terraform 0.8 milestone Oct 28, 2016
@apparentlymart
Copy link
Contributor

I've seen questions about this particular instance of the bug with template_file lots of times on here, so glad to see a fix for it... it has in particular been causing confusion with people using template_file as a data resource, since it confuses the logic for deciding if the data source read needs to be deferred until apply time.

This fix looks plausible, but agreed about the BC concerns given how many people reported phantom bugs in the data sources code due to using template_file interpolations in this way.

@mitchellh
Copy link
Contributor Author

@apparentlymart Yeah this is going to be paired with: hashicorp/hcl#150

That makes the HCL/HIL interaction a lot more sense at the expense of BC

@apparentlymart
Copy link
Contributor

Some more issue references, just to make sure there are link trails from these other issues to here:

@ghost
Copy link

ghost commented Apr 20, 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 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terraform crash - reporting as instructed by the crash
3 participants