Comprehensive documentation and best practices for building Terraform providers with terraform-plugin-framework (v1.17.0). Covers providers, resources, schemas, types, validators, testing, and common pitfalls.
Overall
score
97%
Ensure correct state management and prevent unnecessary "known after apply" values.
Always add UseStateForUnknown() plan modifier to stable computed attributes (IDs, creation timestamps). This prevents unnecessary "(known after apply)" in plans for values that don't change after creation.
Do NOT use it on attributes that change on every update (e.g., last_modified).
resp.State.RemoveResource(ctx) to remove the resource from state gracefullyresp.Diagnostics.AddError() — data sources MUST return an error when the item is not found (never use RemoveResource in a data source)resp.State.Set() -- the framework removes state automaticallyUseStateForUnknown() on IDs -- causes unnecessary plan diffsresp.State.Set() in Delete -- not needed, state is removed automaticallyRemoveResource in a data source Read -- data sources must return an error diagnostic when the item is not foundSee Resources for complete CRUD implementations. See Plan Modifiers for UseStateForUnknown details.