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

[WIP] Support for passing environment variables to dependency blocks #2759

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

juljaeg
Copy link

@juljaeg juljaeg commented Oct 17, 2023

Description

Fixes #2674.

Introduces the ability to pass environment variables to terragrunt configurations which are referenced using the dependency block. There can be general environment variables being passed to every dependency but also environment variables (merged additively) per dependency. The existing get_env function including falling to a default to retreive a value and act accordingly.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.
  • Add some tests.

Known Issues

  • The top-level attribute dependency_env_vars currently is not respected (help appreciated).
  • The attribute on the dependency block is required even tho it can be empty (help appreciated).

Target situation

Fixture test/fixture-dependency-variables can be used as an example.

cd test/fixture-dependency-variables/module-a

VARIANT=a terragrunt apply
terragrunt apply
// Should have terraform-a.tfstate and terraform-default.tfstate now.

cd ../module-b
terragrunt apply
// Is:     Hello World, from B: Hello World, from A: default
// Should: Hello World, from B: Hello World, from A: a

Currently it works when the file is changed to be (see known issues):

# File: module-b/terragrunt.hcl
dependency "a" {
  config_path = "../module-a"

  # Can be optional.
  env_vars = {
    "VARIANT" = "a"
  }
}

[...]

Release Notes (draft)

Added support for passing variables to terragrunt modules being included as dependencies.

Migration Guide

No migration needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Provide way to check whether terragrunt is called by terragrunt
1 participant