Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more abilities to pass common vars to modules similar to Terragrunt #28887

Open
queglay opened this issue Jun 6, 2021 · 0 comments
Open
Labels
enhancement new new issue not yet triaged

Comments

@queglay
Copy link

queglay commented Jun 6, 2021

Current Terraform Version

0.13.7

Use-cases

Providing more efficient use of module blocks with less repetition of common vars in root main.tf files

Attempted Solutions

Terragrunt

Proposal

Currently if we want to pass many common variables into a module block from a root main.tf, we have to explicitly enter each common var into each module block, repeating many common vars across many modules unnecessarily.

Terragrunt has a nice solution to this with

common_vars                  = read_terragrunt_config(find_in_parent_folders("common.hcl"))

and then being able to pass this into each module simply with

inputs = local.common_vars.inputs

It would be really helpful if terraform could pass in a special map as a var like this to module blocks as a standard like...
terraform_common_vars = var.myvarmap

The difference with this ability to standard vars would be:

  • The terraform_common_vars map will treat each key in the map as a var for the module block
  • If keys are in the map that do not exist in the module, this would not cause an error. The behaviour would be similar to using environment variables in this way and be silent.

Some of the benefits of Terragrunt are able to be performed in pure terraform if done carefully, but efficient passing through of common variables is something I haven't yet seen and would be really useful in reducing repetition.

@queglay queglay added enhancement new new issue not yet triaged labels Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

1 participant