terranix
terranix copied to clipboard
Library helper for pre-processing templatefile files
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:
- Knows what variables are to be interpolated in
- 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.
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.