From e825dd0428367e63deaad93fe9c87adbd7acd06d Mon Sep 17 00:00:00 2001 From: tmatias Date: Wed, 31 Jul 2019 19:29:14 -0300 Subject: [PATCH 1/2] make validation on for_each argument more precise --- terraform/eval_for_each.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/eval_for_each.go b/terraform/eval_for_each.go index b86bf3755a97..e737a82913da 100644 --- a/terraform/eval_for_each.go +++ b/terraform/eval_for_each.go @@ -54,7 +54,7 @@ func evaluateResourceForEachExpressionKnown(expr hcl.Expression, ctx EvalContext return map[string]cty.Value{}, false, diags } - if !forEachVal.CanIterateElements() || forEachVal.Type().IsListType() { + if !forEachVal.Type().IsMapType() && !forEachVal.Type().IsSetType() { diags = diags.Append(&hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "Invalid for_each argument", From c20c40c9aae0e8f457eae8f0fc942f9f86b367b3 Mon Sep 17 00:00:00 2001 From: tmatias Date: Thu, 1 Aug 2019 11:33:46 -0300 Subject: [PATCH 2/2] diagnose tuple values being passed as argument to for_each --- terraform/eval_for_each.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/eval_for_each.go b/terraform/eval_for_each.go index e737a82913da..333f65e268ac 100644 --- a/terraform/eval_for_each.go +++ b/terraform/eval_for_each.go @@ -54,7 +54,7 @@ func evaluateResourceForEachExpressionKnown(expr hcl.Expression, ctx EvalContext return map[string]cty.Value{}, false, diags } - if !forEachVal.Type().IsMapType() && !forEachVal.Type().IsSetType() { + if !forEachVal.CanIterateElements() || forEachVal.Type().IsListType() || forEachVal.Type().IsTupleType() { diags = diags.Append(&hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "Invalid for_each argument",