From 1a105edd3893692b83832a8cfa8ce82a04465801 Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 30 Sep 2021 15:36:00 +0800 Subject: [PATCH] fix provider mismatch crash --- internal/meta/hcl_schema.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/meta/hcl_schema.go b/internal/meta/hcl_schema.go index 96045f4..fb09911 100644 --- a/internal/meta/hcl_schema.go +++ b/internal/meta/hcl_schema.go @@ -23,7 +23,14 @@ func tuneHCLSchemaForResource(rb *hclwrite.Body, sch *schema.Schema) error { func tuneForBlock(rb *hclwrite.Body, sch *schema.SchemaBlock, parentAttrNames []string) error { for attrName, attrVal := range rb.Attributes() { - schAttr := sch.Attributes[attrName] + schAttr, ok := sch.Attributes[attrName] + if !ok { + // This might because the provider under used is a newer one than the version where we ingest the schema information. + // This might happen when the user have some newer version provider installed in its local fs. + // We simply remove that attribute from the config. + rb.RemoveAttribute(attrName) + continue + } if schAttr.Required { continue }