4 ms·
There is a dupe Terraform post on Hacker news frontpage. I'll post my comment here too :-) I recommend breaking out your terraform code into separate folders a
by samsquire 5y ago
There is a dupe Terraform post on Hacker news frontpage. I'll post my comment here too :-)
I recommend breaking out your terraform code into separate folders and calling them "components". Write a wrapper around the terraform script to pass in -var-file which uses an argument called ENVIRONMENT that you pass to the wrapper. I think the built in support for modules is less useful for what you actually want to do because you end up with variables spread between variables.tf, outputs.tf files.
I use a tool I wrote to layer my infrastructure with layers called components and I configure it with a Graphviz file.
My tool, called mazzle (previously devops-pipeline) would run parts of the graph that can run in parallel in parallel. It can also run parts of the build on SSH workers. You bring up the workers at the beginning of the build.
Here's an example of a graph generated from graphviz file: https://github.com/samsquire/mazzle-starter/blob/master/architecture.dot https://github.com/samsquire/mazzle-starter/blob/master/arch...
This graph brings up a hashicorp vault server, Java application, bastion proxy, consul, kubernetes, prometheus
here's the graphviz file:
https://github.com/samsquire/mazzle/blob/master/docs/architecture.png https://github.com/samsquire/mazzle/blob/master/docs/archite...
It describes the ordering of the infrastructure, the invocation of Ansible, packer, shell scripts to set up vault etc.
The idea is to be able to bring up a new environment by changing one parameter. There's a React GUI too.
https://devops-pipeline.com https://devops-pipeline.com
- ciisforsuckas 5y agoI've been using Terragrunt to keep my Terraform DRYU in a similar manner. It's a bit of a rethink in how you structure things but I've been happy so far. https://terragrunt.gruntwork.io/ https://terragrunt.gruntwork.io/
- whoomp12342 5y agodoes terragrunt work with azure and GCP or just aws?
- leetrout 5y agoTerragrunt extends Terraform functionality so it works with all Terraform providers.