mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 08:00:17 -06:00
Remove panic, update comment
This commit is contained in:
parent
7c678d104f
commit
e7d8ac5ad7
5
.tfdev
5
.tfdev
@ -6,3 +6,8 @@ version_info {
|
|||||||
|
|
||||||
version_exec = false
|
version_exec = false
|
||||||
disable_provider_requirements = true
|
disable_provider_requirements = true
|
||||||
|
|
||||||
|
platform {
|
||||||
|
os = "darwin"
|
||||||
|
arch = "amd64"
|
||||||
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
data "test" "foo" {
|
|
||||||
for_each = ["a"]
|
|
||||||
}
|
|
@ -16,18 +16,12 @@ import (
|
|||||||
func evaluateResourceForEachExpression(expr hcl.Expression, ctx EvalContext) (forEach map[string]cty.Value, diags tfdiags.Diagnostics) {
|
func evaluateResourceForEachExpression(expr hcl.Expression, ctx EvalContext) (forEach map[string]cty.Value, diags tfdiags.Diagnostics) {
|
||||||
forEachMap, known, diags := evaluateResourceForEachExpressionKnown(expr, ctx)
|
forEachMap, known, diags := evaluateResourceForEachExpressionKnown(expr, ctx)
|
||||||
if !known {
|
if !known {
|
||||||
// Currently this is a rather bad outcome from a UX standpoint, since we have
|
// Attach a diag as we do with count, with the same downsides
|
||||||
// no real mechanism to deal with this situation and all we can do is produce
|
|
||||||
// an error message.
|
|
||||||
// FIXME: In future, implement a built-in mechanism for deferring changes that
|
|
||||||
// can't yet be predicted, and use it to guide the user through several
|
|
||||||
// plan/apply steps until the desired configuration is eventually reached.
|
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
diags = diags.Append(&hcl.Diagnostic{
|
||||||
Severity: hcl.DiagError,
|
Severity: hcl.DiagError,
|
||||||
Summary: "Invalid forEach argument",
|
Summary: "Invalid forEach argument",
|
||||||
Detail: `The "for_each" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the for_each depends on.`,
|
Detail: `The "for_each" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the for_each depends on.`,
|
||||||
})
|
})
|
||||||
panic("uh-oh")
|
|
||||||
}
|
}
|
||||||
return forEachMap, diags
|
return forEachMap, diags
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user