Can I maintain single schema for data-source and resources

Hello Team,

I was working on terraform provider for one of out product, NetScaler SDX using terraform-plugin-framework.

I have created few resources HERE is github repo link. My repo directory structure is as follows, Inside internal folder, I have individual folder with map to each resources, each folder have schema file and resource main login(CRUD skeleton).

I want to have the data source for every resource. Can I use the same schema, I know the types are different (one is resource/schema and other is datasource/schema).
But I don’t want to maintain different schema for simplicity and easy maintenance. How can I achieve that?

Thanks in advance

Hi @rohit-myali :wave:t6:,

Sorry that you’re running into trouble here. Unfortunately, there is not a way to share the schema between data sources and resources as the types have different concepts that are more difficult to abstract into a single shared schema. This GitHub [issue] (New SDK breaks centralized resource schemas · Issue #568 · hashicorp/terraform-plugin-framework · GitHub) has more context about why that decision was made.

A possible option here would be to create your own helper function that converts between the resource/schema and datasource/schema type.