-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
template_file: source contents instead of path #3909
Conversation
"filename": &schema.Schema{ | ||
Type: schema.TypeString, | ||
Required: true, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth adding ConflictsWith
as well? Or warn that filename
is ignored if template
is provided? Minor thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, this is a perfect use case for ConflictsWith
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Building on the work of #3846, deprecate `filename` in favor of a `template` attribute that accepts file contents instead of a path. Required a bit of work in the interpolation code to prevent Terraform from assuming that template interpolations were resource variables that needed to be resolved. Leaving them as "Unknown Variables" prevents interpolation from happening early and lets the `template_file` resource do its thing.
09fc92c
to
928f534
Compare
LGTM. |
template_file: source contents instead of path
@@ -14,7 +14,7 @@ Renders a template from a file. | |||
|
|||
``` | |||
resource "template_file" "init" { | |||
filename = "${path.module}/init.tpl" | |||
template = "${file(${path.module}/init.tpl)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phinze I was updating our configuration due to this PR and tried to update to the configuration above, but it's not proper syntax. It should be template = "${file("${path.module}/init.tpl")}"
Otherwise, you get Error reading config for template_file[init]: parse error: syntax error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops - you're totally right. I see you already filed a PR - thank you!
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. |
Building on the work of #3846, deprecate
filename
in favor of atemplate
attribute that accepts file contents instead of a path.Required a bit of work in the interpolation code to prevent Terraform
from assuming that template interpolations were resource variables that
needed to be resolved. Leaving them as "Unknown Variables" prevents
interpolation from happening early and lets the
template_file
resourcedo its thing.