I am coming from application development so my thought process is bit different. what normally happens with application development is, you have single code base. and based on your branching strategy your pipeline deploys it to multiple environment.
However, with what I am reading for terraform and terrgrunt. people are using different code base for different environment. which would give you a flexibility to have different version of (different memeory, cpu, disk) infra on different environment. However, it’s a lot of code duplicity.
this is what I am reading as standard practice for Google
.
── common
│ └── terraform.hcl
├── environments
│ ├── dev
│ │ ├── project-a
│ │ │ ├── function-1
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── function-2
│ │ │ │ └── terragrunt.hcl
│ │ │ └── function-3
│ │ │ └── terragrunt.hcl
│ ├── qa
│ │ ├── project-a
│ │ │ ├── function-1
│ │ │ │ └── terragrunt.hcl
│ │ │ ├── function-2
│ │ │ │ └── terragrunt.hcl
│ │ │ └── function-3
│ │ │ └── terragrunt.hcl
should there be just single code base, regardless of environment and environment variable should replace the environment specific variables. and now based on which branch I am merging this code (i.e. dev/qa/staging/prod) it would deploy resources on that branch.
I mean something like this.
── common
│ └── terraform.hcl
│ ├── project-a
│ │ ├── function-1
│ │ │ └── terragrunt.hcl
│ │ ├── function-2
│ │ │ └── terragrunt.hcl
│ │ └── function-3
│ │ └── terragrunt.hcl
is this even possible ? if I try to setup what is the challenges I would face ?