diff --git a/backend/remote/backend.go b/backend/remote/backend.go index a6b7051e8..c261f2022 100644 --- a/backend/remote/backend.go +++ b/backend/remote/backend.go @@ -142,6 +142,9 @@ func (b *Remote) ConfigSchema() *configschema.Block { // PrepareConfig implements backend.Backend. func (b *Remote) PrepareConfig(obj cty.Value) (cty.Value, tfdiags.Diagnostics) { var diags tfdiags.Diagnostics + if obj.IsNull() { + return obj, diags + } if val := obj.GetAttr("organization"); val.IsNull() || val.AsString() == "" { diags = diags.Append(tfdiags.AttributeValue( @@ -188,6 +191,9 @@ func (b *Remote) PrepareConfig(obj cty.Value) (cty.Value, tfdiags.Diagnostics) { // Configure implements backend.Enhanced. func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics { var diags tfdiags.Diagnostics + if obj.IsNull() { + return diags + } // Get the hostname. if val := obj.GetAttr("hostname"); !val.IsNull() && val.AsString() != "" { diff --git a/backend/remote/backend_test.go b/backend/remote/backend_test.go index 053a1b35e..8c1e9a80f 100644 --- a/backend/remote/backend_test.go +++ b/backend/remote/backend_test.go @@ -123,6 +123,9 @@ func TestRemote_config(t *testing.T) { }), valErr: `Only one of workspace "name" or "prefix" is allowed`, }, + "null config": { + config: cty.NullVal(cty.EmptyObject), + }, } for name, tc := range cases {