warrensbox/terraform-switcher

Parse terragrunt.hcl and inherit terraform_version_constraint from parent

Opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
We're using terragrunt with a nested moule structure, meaning:

stages
└── test
    └── module1
    └── module2
└── prod
    └── module1
    └── module2

We have terragrunt.hcl in both stages/{stage}, to define global parameters, and in stages/{stage}/{module}, where we define the specific module variable.

We locked the terraform_version_constraint inside stages/{stage}. Running tfswitch from module does not work, we are prompted for a version, so we run it from the module folder.

From time to time we override the terraform_constraint in one specific module. In this scenario, we need to run tfswitch inside the module folder.

This is bad DX and causes issues with CI systems, since we do not have a predictable path to run tfswitch in.

Describe the solution you'd like

It would be helpful to be able to parse the hcl file, so that we would inherit the parent declarations, and behave accordingly.

Each of our modules has an include:

include {
  path = find_in_parent_folders()
}

so, by parsing HCL, the terraform_constraint_version may be inherited from the parent.

Describe alternatives you've considered

Additional context

Have the same use case. Would be nice to have a hierarchical version switch.

Would be nice to have a hierarchical version switch.