Can you have multiple terragrunt.hcl files at the same level? #488
-
I have been working on similar structures for Terraform code for a few years and only recently came across Terragrunt. Certainly looks like it makes things easier and shortens some of the command line length with all of the required var inputs etc. One question that I have is around the break down of code. Take for example a project in an AWS account/region and I want to create multiple VPC, or subnets or any other resource. I have my module in another location and in my repo I basically have the unique values that I pass as variables when calling the module. How this is defined is through multiple Terraform files files, one for each resources, e.g. vpc1.tfvars, vpc2.tfvars etc. I can update one or execute against all of them. With Terragrunt it looks like I have to create the additional abstraction of putting each of these into another sub-directory each with its own terragrunt.hcl file to source the module and provide the inputs. Would this be a fair assumption? It seemed like unnecessary overhead to me when you could achieve the same at the file level. It separate directory or file would also require the duplication of the source reference for the VPC module unless you can link this into a shared location somehow. Please let me know if I am understanding things correctly? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, please take a look at this knowledge base post (note that both answers on the post are relevant, not just the one that is marked) which provides some context and suggestions on how to architect your terragrunt folder structure, as well as touching on the why of how Terragrunt is organized. You will also want to take a look at https://terragrunt.gruntwork.io/docs/features/keep-your-terragrunt-architecture-dry/, which discusses the various features of Terragrunt that help keep the code DRY, such as how to reuse the |
Beta Was this translation helpful? Give feedback.
-
@yorinasub17 I have a context now like upgrading eks module from 19 to 20, But in 20 eks module removed aws-auth to a sub module, so how do we make use of the submodule? i cannot use two source in the same terragrunt.hcl file, below is already present in my current hcl file.
Submodule is in this location tfr:///terraform-aws-modules/eks/aws//modules/aws-auth?version=20.31.6 I tried to create a new directory and created a dedicated terragrunt.hcl file for this submodule and given eks module as dependency.
|
Beta Was this translation helpful? Give feedback.
Hi, please take a look at this knowledge base post (note that both answers on the post are relevant, not just the one that is marked) which provides some context and suggestions on how to architect your terragrunt folder structure, as well as touching on the why of how Terragrunt is organized.
You will also want to take a look at https://terragrunt.gruntwork.io/docs/features/keep-your-terragrunt-architecture-dry/, which discusses the various features of Terragrunt that help keep the code DRY, such as how to reuse the
source
string.