-
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
data source template_file fails with "read /: is a directory" when template attribute interpolation or literal returns a "/" #8660
Comments
I think you're meant to structure it like this: variable "ping_path_separator" {
default = {
HTTP = "/"
HTTPS = "/"
TCP = ""
SSL = ""
}
}
data "template_file" "ping_path_separator" {
template = "${ping_path_separator}"
vars {
ping_path_separator = "${lookup(var.ping_path_separator, "HTTP")}"
}
} |
@jamielennox1 that works indeed. Thanks. Will use that workaround. But I still fail to understand why this specific case fails. I normally do interpolations directly in the |
Filename was deprecated for template. This means we can specify both inline templates and reference template files. / is a directory inside UNIX. So, it's going to assume you're trying to load a file instead of inline. to prove that this is the case: variable "ping_path_separator" {
default = {
HTTP = "Test /"
HTTPS = "/"
TCP = ""
SSL = ""
}
}
data "template_file" "ping_path_separator" {
template = "${lookup(var.ping_path_separator, "HTTP")}"
} This should pass absolutely fine. It's still a bug but hopefully, that helps you to understand why it's behaving the way it is. |
Yeah. Actually I suspected something like that, but then to reproduce the error by using something like this data "template_file" "broken" { template = "/test/" } or data "template_file" "broken" { template = "/test" } or data "template_file" "broken" { template = "test/" } or this data "template_file" "broken" { template = "/test/file.txt" } but none of those failed, only this one data "template_file" "broken" { template = "/" } that got me wondering and opened the ticket. Feel free to close the ticket if this behavior is expected. And thanks again for saving the day :) |
Fixes #8660 This disallows file paths in `template`. This already had a deprecation warning so we're just removing that.
Fixes hashicorp#8660 This disallows file paths in `template`. This already had a deprecation warning so we're just removing that.
Fixes hashicorp#8660 This disallows file paths in `template`. This already had a deprecation warning so we're just removing that.
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. |
Cannot see this in the documentation, so here I go.
terraform plan
fails withread /: is a directory
when the value assigned to thetemplate
attribute of thetemplate_file
data source equals/
.Terraform Version
Terraform v0.7.2
Affected Resource(s)
Terraform Configuration Files
or simply
Expected Behavior
It should not fail an
rendered
should return/
Actual Behavior
It fails as described :)
Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: