Closed cd-bustamante closed 3 years ago
Hey there! the template_file
data source is part of the archived template provider: https://registry.terraform.io/providers/hashicorp/template/latest.
I tried to pull out simplified reproduction case in this repo, to try and help out: https://github.com/danieldreier/terraform-issue-reproductions/tree/master/27706 but was unable to run into the error you have.
Ultimately though, this doesn't appear to be an error in Terraform, but this data source in an archived provider, and we recommend using the templatefile()
function instead, generally. https://www.terraform.io/docs/language/functions/templatefile.html If you run into issues there, when using it as documented, please open another issue.
If you want to continue to debug this issue, I'd recommend using the Community Forums for prior art and assistance.
Thanks for your feedback @pselle , I'll review your input and if required will use the Community Forums. Have a great weekend!
@pselle also for your info the reproduction case you use it is missing a crucial step to reproduce the issue, the call of the variable, example below:
This is the string that triggers the error ==> "${iarray[$c]}"
echo 'iptables -t nat -A PREROUTING -p tcp -d $IP --dport "${iarray[$c]}" -j DNAT --to "${oarray[$c]}"'
echo "iptables -t nat -A POSTROUTING -j MASQUERADE"
echo 'iptables -A FORWARD -p tcp -m tcp --dport "${iarray[$c]}" -j LOG --log-prefix "$PRE-${iarray[$c]}"'
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.
Terraform Version
Terraform Configuration Files
main.tf
provider.tf
datasource.tf
variables.tf
startup_script.sh
Debug Output
https://gist.github.com/cd-bustamante/c86f186df5c8cf310f65c2d5d6f7765c
Crash Output
N/A
Expected Behavior
When running the code, it should be able to create a new VM using template_file, hence the VM should be able to execute the starting up script.
Actual Behavior
Instead of creating the VM I am receiving the following error: Error: failed to render ::61,71-72: Invalid character; This character is not used within the language., and 8 other diagnostic(s)
on datasource.tf line 9, in data "template_file" "init": 9: data "template_file" "init" {
Steps to Reproduce
terraform init
terraform apply
Additional Context
References
First I opened an issue against terraform-provider-google, reference below, they mentioned to follow up on this project with the following comment "This is about the script rendering via data source & template_file." https://github.com/hashicorp/terraform-provider-google/issues/8379