SpEL expression failure interpreting dollar sign bracket with Terraform Templates
Issue
A SpEL expression failure appears while using Terraformer to serialize data from a Terraform Plan execution. The execution creates a JSON object instead of to a JSON string.The customer pipeline does the following:
In the Terraformer Stage, a Terraform Plan outputs a binary object as a Spinnaker Artifact.
Terraform shows passing through a
plan filewhich causes Terraform to output aJSON plan fileas anoutputof the stage.The outputtedplan fileis stored as an artifact that can be used as atfvars objectfor the next Terraformer stage.The command
toJsonis used to ingest the JSON object and transform it into a string. The string will be passed in via atfvarsobject to the subsequentTerraform Apply Stage(with a static/defined by using a module that uploads thetfvars varto a bucket/object)Lastly, the pipeline calls
kubeto run a 3rd party API to download the object through the name passed to it.
The issue is that if the output has a SpEL escape in it ${ then it fails.
Cause
The cause is that the SpEL processor in Spinnaker throws a null value if the SpEL expression has ${ in it, and is visible in Spinnaker's code here Also, if the users are using an older Terraform version (< 0.12), then it is also using the template provider from Terraform.The template provider exposes data sources to use templates to generate strings for other Terraform resources or outputs.
❗️ HashiCorp has deprecated the template provider since v0.12
The announcement is here* Users should use the template file function instead
Last updated
Was this helpful?