From f028b0a2bfb5eb935060c3a5069211ff6a3a9e6f Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Wed, 26 Aug 2020 10:50:47 -0400 Subject: [PATCH] command: Fix backend config schema validation When applying a backend config override file, we must not check for the presence of all required fields, as the override can be a partial configuration. It is only valid to check for required fields after all overrides have been merged, which init already does. --- command/init.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/command/init.go b/command/init.go index d1583d1ef..f328509b5 100644 --- a/command/init.go +++ b/command/init.go @@ -866,10 +866,13 @@ func (c *InitCommand) backendConfigOverrideBody(flags rawFlags, schema *configsc } // Generate an HCL body schema for the backend block. var bodySchema hcl.BodySchema - for name, attr := range schema.Attributes { + for name := range schema.Attributes { + // We intentionally ignore the `Required` attribute here + // because backend config override files can be partial. The + // goal is to make sure we're not loading a file with + // extraneous attributes or blocks. bodySchema.Attributes = append(bodySchema.Attributes, hcl.AttributeSchema{ - Name: name, - Required: attr.Required, + Name: name, }) } for name, block := range schema.BlockTypes {