Skip to content

Commit

Permalink
Add a test for for_each (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed Dec 12, 2022
1 parent 462deea commit a0c90b7
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
45 changes: 45 additions & 0 deletions pkg/tf2pulumi/convert/testdata/for_each/main.tf
@@ -0,0 +1,45 @@
resource "simple_resource" "a_resource_with_foreach_map" {
for_each = {
cruel: "world"
good: "class"
}
input_one = "Hello ${each.key} ${each.value}"
input_two = 0
}

output "some_output_a" {
value = simple_resource.a_resource_with_foreach_map["cruel"].result
}

data "simple_data_source" "a_data_source_with_foreach_map" {
for_each = {
cruel: "world"
good: "class"
}
input_one = "Hello ${each.key} ${each.value}"
input_two = true
}

output "some_output_b" {
value = data.simple_data_source.a_data_source_with_foreach_map["cruel"].result
}

resource "simple_resource" "a_resource_with_foreach_array" {
for_each = ["cruel", "good"]
input_one = "Hello ${each.value} world"
input_two = true
}

output "some_output_c" {
value = simple_resource.a_resource_with_foreach_array["good"].result
}

data "simple_data_source" "a_data_source_with_foreach_array" {
for_each = ["cruel", "good"]
input_one = "Hello ${each.value} world"
input_two = true
}

output "some_output_d" {
value = data.simple_data_source.a_data_source_with_foreach_array["good"].result
}
44 changes: 44 additions & 0 deletions pkg/tf2pulumi/convert/testdata/for_each/pcl/main.pp
@@ -0,0 +1,44 @@
resource aResourceWithForeachMap "simple:index:resource" {
options {
range = {
cruel: "world"
good: "class"
}

}
inputOne = "Hello ${range.key} ${range.value}"
inputTwo = 0
}
output someOutputA {
value = aResourceWithForeachMap["cruel"].result
}
aDataSourceWithForeachMap =[for __key, __value in {
cruel: "world"
good: "class"
}
: invoke("simple:index:data_source", {
inputOne = "Hello ${__key} ${__value}",
inputTwo = true
})]
output someOutputB {
value = aDataSourceWithForeachMap["cruel"].result
}
resource aResourceWithForeachArray "simple:index:resource" {
options {
range = ["cruel", "good"]

}
inputOne = "Hello ${range.value} world"
inputTwo = true
}
output someOutputC {
value = aResourceWithForeachArray["good"].result
}
aDataSourceWithForeachArray =[for __key, __value in ["cruel", "good"]
: invoke("simple:index:data_source", {
inputOne = "Hello ${__value} world",
inputTwo = true
})]
output someOutputD {
value = aDataSourceWithForeachArray["good"].result
}

0 comments on commit a0c90b7

Please sign in to comment.