As Terraform is a state machine, there is no reason Terraform couldn't wrap and execute itself.
- Workspaces are shit!
- Configuring backends are a pain!
- You have to embed modules into modules to track cascading changes between them
- Noisy directory structure
- Deleting .hcl doesn't destroy that module implementation, so it needs destroying first before deletion.
- Changes still don't cascade fully.
- You need to install another binary to run Terraform
Create a Terraform provider to wrap terraform.
- You can exploit Terraforms own syntax to drive it
- You can run your modules in isolation
- You can wire module outputs to the inputs of another
- Deleting a module from the configuration, can cause terraform to run a destroy operation
- You can easily target a specific module implementation using Terraforms own
-target
switch. - You'll get some seriously DRY terraform projects.
- You should no longer need to use
terraform_remote_state
due to wiring between modules.
Using this method your terraform modules should be extremely DRY, only requiring top-level .tf files for wrapping your module configuration, then a folder structure for your modules
project
│ main.tf # your wrapper terraform file
│
└───modules
│
└───aws-vpc
│ main.tf
└───aws-alb
main.tf
- We could create a similar product for SAM and CloudFormation, allowing us to wire Inputs/Variables/Outputs between them and Terraform removing the need for hacky solutions for resource information.