-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes: recursive loop when parent and child module has same local block
- Loading branch information
Showing
10 changed files
with
145 additions
and
10 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
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
21 changes: 21 additions & 0 deletions
21
pkg/iac-providers/terraform/v14/testdata/recursive-loop-duplicate-locals/dummy/main.tf
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 @@ | ||
variable "tags" { | ||
type = map | ||
} | ||
|
||
variable "name" { type = string } | ||
variable "prefix" { type = string } | ||
|
||
locals { | ||
common_tags = merge({ | ||
CreatedBy = "Terraform" | ||
}, var.tags) | ||
name = var.prefix != "" ? "${var.prefix}-${var.name}" : var.name | ||
} | ||
|
||
resource "aws_iam_user" "lb" { | ||
name = local.name | ||
tags = merge(local.common_tags, | ||
{ | ||
Name = local.name | ||
}) | ||
} |
16 changes: 16 additions & 0 deletions
16
pkg/iac-providers/terraform/v14/testdata/recursive-loop-duplicate-locals/main.tf
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,16 @@ | ||
locals { | ||
common_tags = { | ||
this = "that" | ||
} | ||
} | ||
|
||
module "dummy" { | ||
source = "./dummy" | ||
|
||
tags = local.common_tags | ||
name = "fred" | ||
prefix = "joe" | ||
} | ||
|
||
|
||
|
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
20 changes: 20 additions & 0 deletions
20
pkg/iac-providers/terraform/v14/testdata/tfjson/recursive-loop-duplicate-locals.json
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,20 @@ | ||
{ | ||
"aws_iam_user": [ | ||
{ | ||
"id": "aws_iam_user.lb", | ||
"name": "lb", | ||
"module_name": "dummy", | ||
"source": "dummy/main.tf", | ||
"plan_root": "./", | ||
"line": 15, | ||
"type": "aws_iam_user", | ||
"config": { | ||
"name": "joe != \"\" ? \"joe-fred\" : fred", | ||
"tags": "${merge(${merge({\n CreatedBy = \"Terraform\"\n }, {\"this\":\"that\"})},\n {\n Name = joe != \"\" ? \"joe-fred\" : fred\n })}" | ||
}, | ||
"skip_rules": null, | ||
"max_severity": "", | ||
"min_severity": "" | ||
} | ||
] | ||
} |
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