hashicorp / terraform-provider-template

Terraform template provider
https://www.terraform.io/docs/providers/template/
Mozilla Public License 2.0
131 stars 89 forks source link

Template 2.0.0 tries to interpulate percent (%) signs followed by curly-braces {} #51

Closed ayashjorden closed 5 years ago

ayashjorden commented 5 years ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.11.7
+ provider.archive v1.1.0
+ provider.aws v1.38.0
+ provider.dyn v1.1.0
+ provider.local v1.1.0
+ provider.null v1.0.0
+ provider.random v2.0.0
+ provider.template v2.0.0

Your version of Terraform is out of date! The latest version
is 0.11.11. You can update by downloading from www.terraform.io/downloads.html

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Template body

status=$(curl $ETCD_CURLOPTS -f -s -w **%{http_code}** "$etcd_good_member_url/v2/members/$bp" -XDELETE)

^^^ the %{http_code} causes the error

Debug Output

* module.MY_MODULE.data.template_file.install_script: data.template_file.install_script: failed to render : <template_file>:153,57-66: Invalid template control keyword; "http_code" is not a valid template control keyword.

Expected Behavior

TF template provider should not try to interpulate percent signs.

Actual Behavior

See Debug Output

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create a template with %{http_code} as body
  2. Using TF 0.11.7, try to render the template.

Thank you in advance, Yarden

apparentlymart commented 5 years ago

Hi @ayashjorden,

This was an intentional change of behavior in the 2.0.0 major release of the template provider in order to introduce the for and if constructs.

To retain the old behavior, you can add a version constraint to your configuration as recommended by terraform init:

provider "template" {
  version = "~> 1.0"
}

Alternatively, you can escape the sequence by doubling the percent sign, giving %%{http_code}.

For more information on what changed in the 2.0.0 release, see the changelog.

fabouya commented 5 years ago

Hi, double escaping does not work : Error message : "http_code" is not a valid template control keyword template : CODE=curl --output join.sh --silent -w "%%{http_code}" "http://${MASTERIP}/join.txt" Provider for Openstack v "2.0.0"

mayurva commented 4 years ago

For anyone who stumbles onto this in future, escaping with %% worked for me