terranix icon indicating copy to clipboard operation
terranix copied to clipboard

Library helper for pre-processing templatefile files

Open colemickens opened this issue 4 years ago • 1 comments

Since Terraform abusively re-uses their hcl parser to templatize templatefile files, properly written bash scripts are... incompatible with it by default.

I'd like to see a wrapper that:

  1. Knows what variables are to be interpolated in
  2. Replaces all ${vars} (that don't appear in the interpolation list) with $${vars}

Then templatefile will do the right thing while not forcing users to manually ... break their bash scripts just to work with templatefile.

colemickens avatar Oct 23 '21 03:10 colemickens

alternatively, one could make a header that gets run through templatefile, simply appending the original script afterward, without templating, doing this:

#!/usr/bin/env bash
export $${TF_VAR} = ${TF_VAR}

for every var that should be interpolated, since there's already an assumption this is a script.

colemickens avatar Oct 23 '21 03:10 colemickens