-
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.
feat(terraform): TF Dynamic Blocks support -
for_each
lists type (#…
…3737) * Support Dynamic Blocks list type + UTs * Fix UT * remove unrelated file
- Loading branch information
1 parent
106560d
commit f65d1b0
Showing
12 changed files
with
193 additions
and
14 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
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
28 changes: 28 additions & 0 deletions
28
...raph/variable_rendering/test_resources/dynamic_blocks_resource/dynamic_block_with_list.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,28 @@ | ||
locals { | ||
inbound_ports = [80, 443] | ||
outbound_ports = [443, 1433] | ||
} | ||
|
||
resource "aws_security_group" "list_example" { | ||
name = "list-example" | ||
|
||
dynamic "ingress" { | ||
for_each = local.inbound_ports | ||
content { | ||
from_port = ingress.value | ||
to_port = ingress.value | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
dynamic "egress" { | ||
for_each = local.outbound_ports | ||
content { | ||
from_port = egress.value | ||
to_port = egress.value | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/terraform/graph/variable_rendering/test_resources/dynamic_blocks_tfvars/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,24 @@ | ||
resource "aws_security_group" "list_example" { | ||
name = "list-example" | ||
|
||
dynamic "ingress" { | ||
for_each = var.dynamic.inbound_ports | ||
content { | ||
from_port = ingress.value | ||
to_port = ingress.value | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
dynamic "egress" { | ||
for_each = var.dynamic.outbound_ports | ||
content { | ||
from_port = egress.value | ||
to_port = egress.value | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
.../terraform/graph/variable_rendering/test_resources/dynamic_blocks_tfvars/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,4 @@ | ||
dynamic = { | ||
inbound_ports = [80, 443] | ||
outbound_ports = [443, 1433] | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/terraform/graph/variable_rendering/test_resources/dynamic_blocks_tfvars/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,7 @@ | ||
variable "dynamic" { | ||
description = "TODO" | ||
type = object({ | ||
outbound_ports = list(string) | ||
inbound_ports = list(string) | ||
}) | ||
} |
24 changes: 24 additions & 0 deletions
24
...rraform/graph/variable_rendering/test_resources/dynamic_blocks_variable_rendering/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,24 @@ | ||
resource "aws_security_group" "list_example" { | ||
name = "list-example" | ||
|
||
dynamic "ingress" { | ||
for_each = var.dynamic.inbound_ports | ||
content { | ||
from_port = ingress.value | ||
to_port = ingress.value | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
dynamic "egress" { | ||
for_each = var.dynamic.outbound_ports | ||
content { | ||
from_port = egress.value | ||
to_port = egress.value | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
...rm/graph/variable_rendering/test_resources/dynamic_blocks_variable_rendering/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,4 @@ | ||
variable "dynamic" { | ||
inbound_ports = [80, 443] | ||
outbound_ports = [443, 1433] | ||
} |