Move things around, add test for resource references
This commit is contained in:
parent
0f3d8b4884
commit
35016a5ea3
|
@ -50,7 +50,7 @@ func evaluateResourceForEachExpressionKnown(expr hcl.Expression, ctx EvalContext
|
||||||
Subject: expr.Range().Ptr(),
|
Subject: expr.Range().Ptr(),
|
||||||
})
|
})
|
||||||
return nil, true, diags
|
return nil, true, diags
|
||||||
case !forEachVal.IsWhollyKnown():
|
case !forEachVal.IsKnown():
|
||||||
return map[string]cty.Value{}, false, diags
|
return map[string]cty.Value{}, false, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,11 @@ func evaluateResourceForEachExpressionKnown(expr hcl.Expression, ctx EvalContext
|
||||||
})
|
})
|
||||||
return nil, true, diags
|
return nil, true, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For sets, we need to recursively check ...and add reasoning why this works here
|
||||||
|
if !forEachVal.IsWhollyKnown() {
|
||||||
|
return map[string]cty.Value{}, false, diags
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the map is empty ({}), return an empty map, because cty will return nil when representing {} AsValueMap
|
// If the map is empty ({}), return an empty map, because cty will return nil when representing {} AsValueMap
|
||||||
|
|
|
@ -553,7 +553,25 @@ aws_instance.foo["e30a7edcc42a846684f2a4eea5f3cd261d33c46d"]:
|
||||||
ID = foo
|
ID = foo
|
||||||
provider = provider.aws
|
provider = provider.aws
|
||||||
foo = foo
|
foo = foo
|
||||||
type = aws_instance`
|
type = aws_instance
|
||||||
|
aws_instance.one["a"]:
|
||||||
|
ID = foo
|
||||||
|
provider = provider.aws
|
||||||
|
aws_instance.one["b"]:
|
||||||
|
ID = foo
|
||||||
|
provider = provider.aws
|
||||||
|
aws_instance.two["a"]:
|
||||||
|
ID = foo
|
||||||
|
provider = provider.aws
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
aws_instance.one
|
||||||
|
aws_instance.two["b"]:
|
||||||
|
ID = foo
|
||||||
|
provider = provider.aws
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
aws_instance.one`
|
||||||
const testTerraformApplyMinimalStr = `
|
const testTerraformApplyMinimalStr = `
|
||||||
aws_instance.bar:
|
aws_instance.bar:
|
||||||
ID = foo
|
ID = foo
|
||||||
|
|
|
@ -9,3 +9,12 @@ resource "aws_instance" "foo" {
|
||||||
)
|
)
|
||||||
foo = "foo"
|
foo = "foo"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# referencing another resource, which means it has some unknown values in it
|
||||||
|
resource "aws_instance" "one" {
|
||||||
|
for_each = toset(["a", "b"])
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "two" {
|
||||||
|
for_each = aws_instance.one
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue