by iliaxj · 1y ago · 0 comments
- root
-- /envs
--- / dev.tfvars
--- / prod.tfvars
- main.tf
When it gets deployed by the CICD, the right tfvars file is passed in via the -var-file parameter. A standard `env` var is also passed in, and used as a basis for a naming convention. Backend is also set by the pipeline.The rationale here is that our environments should be almost the same between them, and any variations should be accomplished by parameterization.
Modules are kept either in separate repos, if they need to be shared between many workspaces, or under the `modules` subfolder.
- root
-- /envs
--- / .dev.env
--- / .test.env
--- / .prod.env
--- / dev.tfvars
--- / test.tfvars
--- / prod.tfvars
- 1_create_network.tf
- 2_create_storage.tf
- 3_create_service.tf
https://www.youtube.com/watch?v=WgPQ-nm_ers Compliance At Scale: Hardened Terraform Modules at Morgan StanleyThen sure sprinkle a few per-env-toggles `count: 1 if env == dev else 0` (or whatever the latest nicest way to do that is today), but it feels weird to have to set up an artificial TF module around our entire codebase to be able to share the bulk of the code?
module "cool_name" {
count = var.create_cool_name ? 1 : 0
}
I've always wanted a simple enable/disable syntax for modules in tf.