How can I keep a "local" tf module next to/close to the terragrunt.hcl? #559
-
|
Hi, I'm fairly new to terragrunt, so apologies if I'm asking something with an obvious answer. I'm confused by this section in the example tutorial: This seems to hint at a capability what I want, but I can't get it to work. I have some terraform modules that are fairly generic and shared over some terragrunt directories. I have them on the same filesystem (not in git). It looks more or less like this: For one of terragrunt.hcl files, I need a little bit of local customization in how a shared module ( My problem is I cannot figure out how to achieve this. I don't want to create another module in the "shared" modules directory which is specifically only serves as an "entry point" module for one specific environment. I'd rather keep the terraform code "close" to the terragrunt.hcl it applies to. I've tried to have the I've also tried having a Really my question is, if I have shared terraform modules, and my environments have slight dissimilarities in how those shared modules are invoked, how must I structure the terragrunt repository to accomplish this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Hi,
References: I also created some examples using I hope this helps |
Beta Was this translation helpful? Give feedback.
-
|
I am having a similar issue, thus I won't create a new discussion and put it here: In my child terraform {
source = "${path_relative_from_include()}/modules//vpc" # also tried: source = "../../../modules/vpc" with the same effect
}In the root directory I also have But if I remove the above code and put Terraform module "vpc" {
source = "../../../modules/vpc"
...The simplified files structure: How can I get rid of this Disclaimer: I am new to terragrunt, sorry! |
Beta Was this translation helpful? Give feedback.
-
|
Looks like it wasn't working because of the |
Beta Was this translation helpful? Give feedback.
Hi,
AFAIK, it depends on how big are dissimilarities:
dependencyblock and outputs passed toapplication-cache- but it will require to extract terraform code as separated module and reference it in Terragruntgenerateblock to put custom code in the module directory before the invocation of TerraformReferences:
https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#dependency
https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#generate
I also created some examples using
generateanddependencyin https://github.com/denis256/terragrunt-tests/tree/master/discussion-559I hope this helps