don't allow count && for_each
This commit is contained in:
parent
6ec5e0fc88
commit
939d045a0b
|
@ -71,6 +71,15 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno
|
|||
}
|
||||
|
||||
if attr, exists := content.Attributes["for_each"]; exists {
|
||||
if mc.Count != nil {
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: `Invalid combination of "count" and "for_each"`,
|
||||
Detail: `The "count" and "for_each" meta-arguments are mutually-exclusive, only one should be used to be explicit about the number of resources to be created.`,
|
||||
Subject: &attr.NameRange,
|
||||
})
|
||||
}
|
||||
|
||||
mc.ForEach = attr.Expr
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ func TestLoadModuleCall(t *testing.T) {
|
|||
file, diags := parser.LoadConfigFile("module-calls.tf")
|
||||
assertExactDiagnostics(t, diags, []string{
|
||||
`module-calls.tf:22,3-13: Reserved argument name in module block; The name "depends_on" is reserved for use in a future version of Terraform.`,
|
||||
`module-calls.tf:20,3-11: Invalid combination of "count" and "for_each"; The "count" and "for_each" meta-arguments are mutually-exclusive, only one should be used to be explicit about the number of resources to be created.`,
|
||||
})
|
||||
|
||||
gotModules := file.ModuleCalls
|
||||
|
|
Loading…
Reference in New Issue