diff --git a/schema/schema_merge.go b/schema/schema_merge.go index 22ef4786..b3e1d7f9 100644 --- a/schema/schema_merge.go +++ b/schema/schema_merge.go @@ -157,7 +157,7 @@ func (m *SchemaMerger) SchemaForModule(meta *tfmod.Meta) (*schema.BodySchema, er remoteStateDs.Attributes["backend"].Constraint = backends.BackendTypesAsOneOfConstraint(m.terraformVersion) delete(remoteStateDs.Attributes, "config") - depBodies := m.dependentBodyForRemoteStateDataSource(providerAddr, localRef) + depBodies := m.dependentBodyForRemoteStateDataSource(remoteStateDs, providerAddr, localRef) for key, depBody := range depBodies { mergedSchema.Blocks["data"].DependentBody[key] = depBody if _, ok := mergedSchema.Blocks["check"]; ok { diff --git a/schema/schema_merge_remote_state_ds.go b/schema/schema_merge_remote_state_ds.go index a2d692c8..2de204f3 100644 --- a/schema/schema_merge_remote_state_ds.go +++ b/schema/schema_merge_remote_state_ds.go @@ -24,7 +24,7 @@ func isRemoteStateDataSource(pAddr tfaddr.Provider, dsName string) bool { dsName == remoteStateDsName } -func (sm *SchemaMerger) dependentBodyForRemoteStateDataSource(providerAddr lang.Address, localRef module.ProviderRef) map[schema.SchemaKey]*schema.BodySchema { +func (sm *SchemaMerger) dependentBodyForRemoteStateDataSource(originalBodySchema *schema.BodySchema, providerAddr lang.Address, localRef module.ProviderRef) map[schema.SchemaKey]*schema.BodySchema { m := make(map[schema.SchemaKey]*schema.BodySchema, 0) backendsAsCons := backends.ConfigsAsObjectConstraint(sm.terraformVersion) @@ -49,18 +49,15 @@ func (sm *SchemaMerger) dependentBodyForRemoteStateDataSource(providerAddr lang. }, } - dsSchema := &schema.BodySchema{ - Attributes: map[string]*schema.AttributeSchema{ - "backend": { - Constraint: backends.BackendTypesAsOneOfConstraint(sm.terraformVersion), - IsRequired: true, - SemanticTokenModifiers: lang.SemanticTokenModifiers{lang.TokenModifierDependent}, - }, - "config": { - Constraint: objConstraint, - IsOptional: true, - }, - }, + dsSchema := originalBodySchema.Copy() + dsSchema.Attributes["backend"] = &schema.AttributeSchema{ + Constraint: backends.BackendTypesAsOneOfConstraint(sm.terraformVersion), + IsRequired: true, + SemanticTokenModifiers: lang.SemanticTokenModifiers{lang.TokenModifierDependent}, + } + dsSchema.Attributes["config"] = &schema.AttributeSchema{ + Constraint: objConstraint, + IsOptional: true, } m[schema.NewSchemaKey(depKeys)] = dsSchema