diff --git a/.tfdev b/.tfdev index a04d5c102..8779d0181 100644 --- a/.tfdev +++ b/.tfdev @@ -6,3 +6,8 @@ version_info { version_exec = false disable_provider_requirements = true + +platform { + os = "darwin" + arch = "amd64" +} diff --git a/configs/testdata/invalid-files/data-count-and-for-each.tf b/configs/testdata/invalid-files/data-count-and-for_each.tf similarity index 100% rename from configs/testdata/invalid-files/data-count-and-for-each.tf rename to configs/testdata/invalid-files/data-count-and-for_each.tf diff --git a/configs/testdata/invalid-files/data-reserved-for_each.tf b/configs/testdata/invalid-files/data-reserved-for_each.tf deleted file mode 100644 index 1ccc01bfb..000000000 --- a/configs/testdata/invalid-files/data-reserved-for_each.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "test" "foo" { - for_each = ["a"] -} diff --git a/terraform/eval_for_each.go b/terraform/eval_for_each.go index a49d0686e..b86bf3755 100644 --- a/terraform/eval_for_each.go +++ b/terraform/eval_for_each.go @@ -16,18 +16,12 @@ import ( func evaluateResourceForEachExpression(expr hcl.Expression, ctx EvalContext) (forEach map[string]cty.Value, diags tfdiags.Diagnostics) { forEachMap, known, diags := evaluateResourceForEachExpressionKnown(expr, ctx) if !known { - // Currently this is a rather bad outcome from a UX standpoint, since we have - // 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. + // Attach a diag as we do with count, with the same downsides diags = diags.Append(&hcl.Diagnostic{ Severity: hcl.DiagError, 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.`, }) - panic("uh-oh") } return forEachMap, diags }