-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with parsing for a cascading dependencies case, Fix Duplica…
…ted dependencies, Handle Relative/Absolute Paths more gracefully (#113) * Add test case for cascading dependencies bug * Dependencies: Fix parse for cascade, Fix duplicates - Improvement: In order to fix the issue with cascading dependencies this add extra checks to handle both the case that a dependency uses an absolute path or a relative one. - Improvement: Also converts relative dependencies to absolute to avoid duplicates and re-converts the dependencies to relative before the configuration file is generated. - Fix: Creates new terragrunt options with the dependency path in order to be able to parse successfully the cascading dependencies.
- Loading branch information
1 parent
b8d7c61
commit 25f1d46
Showing
10 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
automerge: false | ||
parallel_apply: true | ||
parallel_plan: true | ||
projects: | ||
- autoplan: | ||
enabled: false | ||
when_modified: | ||
- '*.hcl' | ||
- '*.tf*' | ||
dir: network-account/eu-west-1/network/transit-gateway | ||
- autoplan: | ||
enabled: false | ||
when_modified: | ||
- '*.hcl' | ||
- '*.tf*' | ||
- ../../../env-a/network/vpc/terragrunt.hcl | ||
- ../../../../../network-account/eu-west-1/network/transit-gateway/terragrunt.hcl | ||
dir: prod/eu-west-1/_global/route53/test-zone | ||
- autoplan: | ||
enabled: false | ||
when_modified: | ||
- '*.hcl' | ||
- '*.tf*' | ||
- ../../../../../network-account/eu-west-1/network/transit-gateway/terragrunt.hcl | ||
dir: prod/eu-west-1/env-a/network/vpc | ||
version: 3 |
3 changes: 3 additions & 0 deletions
3
test_examples/multi_accounts_vpc_route53_tgw/network-account/eu-west-1/network/env.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
locals { | ||
env = "network" | ||
} |
21 changes: 21 additions & 0 deletions
21
...accounts_vpc_route53_tgw/network-account/eu-west-1/network/transit-gateway/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the | ||
# working directory, into a temporary folder, and execute your Terraform commands in that folder. | ||
terraform { | ||
source = "git::[email protected]:gruntwork-io/terragrunt-infrastructure-modules-example.git//tgw?ref=v0.3.0" | ||
} | ||
|
||
# Include all settings from the root terragrunt.hcl file | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
locals { | ||
# Automatically load environment-level variables | ||
env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) | ||
# Extract out common variables for reuse | ||
env_name = local.env_vars.locals.env | ||
} | ||
|
||
inputs = { | ||
name = "tgw-${local.env_name}" | ||
} |
3 changes: 3 additions & 0 deletions
3
test_examples/multi_accounts_vpc_route53_tgw/prod/eu-west-1/_global/env.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
locals { | ||
env = "global-region" | ||
} |
28 changes: 28 additions & 0 deletions
28
...es/multi_accounts_vpc_route53_tgw/prod/eu-west-1/_global/route53/test-zone/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
locals { | ||
# Automatically load environment-level variables | ||
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) | ||
|
||
# Extract out common variables for reuse | ||
env = local.environment_vars.locals.env | ||
} | ||
|
||
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the | ||
# working directory, into a temporary folder, and execute your Terraform commands in that folder. | ||
terraform { | ||
source = "git::[email protected]:gruntwork-io/terragrunt-infrastructure-modules-example.git//zone?ref=v0.3.0" | ||
} | ||
|
||
# Include all settings from the root terragrunt.hcl file | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
dependency "vpc" { | ||
config_path = "../../../env-a/network/vpc/" | ||
} | ||
|
||
# These are the variables we have to pass in to use the module specified in the terragrunt configuration above | ||
inputs = { | ||
name = "test_zone_${local.env}" | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
test_examples/multi_accounts_vpc_route53_tgw/prod/eu-west-1/env-a/env.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
locals { | ||
env = "env-a" | ||
stack_name = "Environment-a" | ||
} |
26 changes: 26 additions & 0 deletions
26
test_examples/multi_accounts_vpc_route53_tgw/prod/eu-west-1/env-a/network/vpc/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the | ||
# working directory, into a temporary folder, and execute your Terraform commands in that folder. | ||
terraform { | ||
source = "git::[email protected]:gruntwork-io/terragrunt-infrastructure-modules-example.git//vpc?ref=v0.3.0" | ||
} | ||
|
||
# Include all settings from the root terragrunt.hcl file | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
locals { | ||
# Automatically load environment-level variables | ||
env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) | ||
# Extract out common variables for reuse | ||
stack_name = local.env_vars.locals.stack_name | ||
} | ||
|
||
dependency "tgw" { | ||
config_path = "../../../../../network-account/eu-west-1/network/transit-gateway/" | ||
} | ||
|
||
inputs = { | ||
name = local.stack_name | ||
transit_gateway_id = dependency.tgw.outputs.this_ec2_transit_gateway_id | ||
} |
18 changes: 18 additions & 0 deletions
18
test_examples/multi_accounts_vpc_route53_tgw/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
locals { | ||
|
||
# Automatically load environment-level variables | ||
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) | ||
|
||
} | ||
|
||
# --------------------------------------------------------------------------------------------------------------------- | ||
# GLOBAL PARAMETERS | ||
# These variables apply to all configurations in this subfolder. These are automatically merged into the child | ||
# `terragrunt.hcl` config via the include block. | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
# Configure root level variables that all resources can inherit. This is especially helpful with multi-account configs | ||
# where terraform_remote_state data sources are placed directly into the modules. | ||
inputs = merge( | ||
local.environment_vars.locals, | ||
) |