Terraform: template_file provider does not report line number or variable for syntax errors

Created on 11 Sep 2015  ·  15Comments  ·  Source: hashicorp/terraform

This makes for a situation that is difficult to debug:

...
Error applying plan:

2 error(s) occurred:

* template_file.services-init: failed to render scripts/init-services.tpl: parse error: syntax error
* template_file.compute-init: failed to render scripts/init-compute.tpl: parse error: syntax error

What errors and where, can Terraform tell me?

bug providetemplate

Most helpful comment

This should be fixed now (in 0.8 series)

All 15 comments

+1

It's very difficult to troubleshoot this. I even get it using the stock example from the docs.

+1

+1

I'll vote for this too. I was only able to find the error by applying every git commit, to find the one that introduced the failure.

This problem is made worse by the fact that plan doesn't seem to actually evaluate the template, so it doesn't show an error. Not only do we not get any further feedback, but the syntax error is only visible on an actual apply.

+1

+1

Any update on this?

+1

It does look like we could run hil.Parse in the validate func to get some initial template syntax validation before apply.

For the actual error contents, it looks like Terraform is just passing through verbatim the error returned from hil.Parse, so getting a source location here will probably require changes to hil.

+1

👍

+1

+1

This should be fixed now (in 0.8 series)

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