3 ms·
+1 for the question about a "standard" or recommended way to parse and generate .tf files from a script. I have two use cases in mind: Use case 1: need to have
by ivan_ah 7y ago
+1 for the question about a "standard" or recommended way to parse and generate .tf files from a script.
I have two use cases in mind:
Use case 1: need to have a reproducible way to generate terraform folders for multiple almost-identical deployments (this can be solved via modules)
Use case 2: need way to "promote" a deployment from staging to production (load a .tf file, change a few basic params then save again to a different folder --- doesn't really work with templates since I want to load an existing .tf file)
One thing that might work is to use the combination of two tools:
- https://github.com/virtuald/pyhcl https://github.com/virtuald/pyhcl = reads .tf, can export .tf.json
- https://github.com/kvz/json2hcl https://github.com/kvz/json2hcl = convert .tf.json to .tf
but feels hacky...
Any other recommendations for .tf parsing and generation? (preferably in python or scriptable via python)
- robfig 7y agoYour favorite tool that produces json should be able to work. I'd probably use jsonnet, which has a multi-file mode so that one template file can render into many json files.