Get interpolated JSON template file

I have I resource which is using templatefile (which after interpolation will be just JSON).

Is there any terraform command/any tool which allows to get interpolated values with some sample values? For example:

resource some_resource my resource {
    json_content = templatefile("json-template.tpl", {
    name        = "John Smith"
  })

example file

{
  "name": "${name}"
}

in my Python tests I wanna get this file with interplated values :slight_smile: Any idea?

Hi @myslak71,

Iโ€™m not 100% clear on what youโ€™re asking for here, but I think you want to see, outside the module what is being passed into json_content to then use it in an external test?

If this is the case then, in this instance, I would probably do the following:

  1. Use a local variable to hold the output of the templatefile()
  2. Reference that local as the value of your json_content
  3. either
    3a. Use an output to expose the local value directly to outside the module and process as required.
    or
    3b. use the local_file Resource and set the content of that resource to the local variable to write it out as a file which could then be used as an artefact as part of the testing.

Hope that helps.

Happy Terraforming