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

template_file: source contents instead of path #3909

Merged
merged 1 commit into from Nov 16, 2015

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Nov 13, 2015

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.

"filename": &schema.Schema{
Type: schema.TypeString,
Required: true,
Optional: true,
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
@jen20
Copy link
Contributor

jen20 commented Nov 15, 2015

LGTM.

phinze added a commit that referenced this pull request Nov 16, 2015
template_file: source contents instead of path
@phinze phinze merged commit 993ec0a into master Nov 16, 2015
@phinze phinze deleted the phinze/template-file-contents branch November 16, 2015 20:50
@@ -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)}"
Copy link
Contributor

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

Copy link
Contributor Author

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!

@ghost
Copy link

ghost commented Apr 30, 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 30, 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.

None yet

4 participants