Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

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

Closed
ayashjorden opened this issue Jan 17, 2019 · 3 comments

Comments

@ayashjorden
Copy link

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:

  • template_file

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
Copy link
Contributor

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
Copy link

fabouya commented Jan 29, 2019

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
Copy link

mayurva commented Feb 27, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants