-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(terraform): Fix foreach multi attributes in field (#6707)
Fix(terraform): Fix foreach multi attributes in field
- Loading branch information
1 parent
eb053df
commit 3e4f1bb
Showing
5 changed files
with
53 additions
and
2 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
11 changes: 11 additions & 0 deletions
11
tests/terraform/graph/variable_rendering/test_resources/dynamic_blocks_tfvars_merge/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,11 @@ | ||
|
||
resource "aws_instance" "this" { | ||
for_each = { for host in var.vmhosts : host.name => host } | ||
|
||
instance_type = var.instance_type | ||
key_name = var.key_name | ||
private_ip = each.value.private_ip | ||
|
||
tags = merge(each.value.tags, { Name = each.value.name }, {}) | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...form/graph/variable_rendering/test_resources/dynamic_blocks_tfvars_merge/terraform.tfvars
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 @@ | ||
|
||
key_name = "test1" | ||
vmhosts = [ | ||
{ | ||
name = "vm1" | ||
tags = { Environment = "prod", Department = "Testing" } | ||
private_ip = "11.101.33.254" | ||
ports = [ 22 ] | ||
}, | ||
{ | ||
name = "vm2" | ||
tags = { Environment = "Test" } | ||
private_ip = "22.212.0.200" | ||
ports = [ 80 ] | ||
} | ||
] |
17 changes: 17 additions & 0 deletions
17
...erraform/graph/variable_rendering/test_resources/dynamic_blocks_tfvars_merge/variables.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,17 @@ | ||
variable "instance_type" { | ||
default = "t3.small" | ||
} | ||
|
||
variable "key_name" { | ||
type = string | ||
} | ||
|
||
variable "vmhosts" { | ||
description = "VM hosts with configuration" | ||
type = list(object({ | ||
name = string | ||
tags = map(string) | ||
private_ip = string | ||
ports = list(number) | ||
})) | ||
} |