boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

[FEATURE] Support templating for Pass Files #341

Open syepes opened 10 months ago

syepes commented 10 months ago

Summary

Add support for ruby templating with the Terraspace context for specific file under the Pass Files folder

Motivation

Having this extra templating extension .erb would allow the generation of dynamic configuration files based on the terraspace deployment context. This would allow to have more flexibility with the deployments and have one single solution.

Guide-level explanation

0) Keep the current supported Pass Files extension functionality untouched (.tf, .tfvars and .rb) 1) Add support for a new extension like .erb that adds this templating functionality 2) Any files in config.build.pass_files that match this extension will be processed and all their expansions would be evaluated 3) When moving the matched .erb files to the final build folder the extra extension fill be removed to keep the original filename. e.g.

config.yaml.erb --> files/config.yaml
config.json.erb --> files/config.json

Reference discussion:

https://community.boltops.com/t/terraform-tfvars-templating-is-not-filled-in/750/5