Implement Terraform Provider resources and data sources using the Plugin Framework. Use when developing CRUD operations, schema design, state management, and acceptance testing for provider resources.
This skill provides comprehensive guidance for implementing Terraform Provider resources and data sources using the Terraform Plugin Framework. It addresses the challenge of developing reliable infrastructure-as-code providers by offering structured patterns for CRUD operations, schema design, state management, and acceptance testing. The skill focuses on the technical implementation details needed to build production-ready Terraform providers that manage cloud infrastructure resources.
The main capabilities include implementing both SDKv2 and Plugin Framework resource patterns, designing robust schemas with proper validation and plan modifiers, managing resource state and lifecycle operations, and structuring provider code according to established conventions. It covers the complete resource development workflow from file organization to CRUD operation implementation, including proper error handling, tagging support, and import functionality.
This skill is specifically designed for platform engineers, infrastructure developers, and DevOps engineers who are building custom Terraform providers or extending existing ones. It's particularly valuable when developing resources for proprietary APIs, internal services, or specialized infrastructure components that need to integrate with Terraform's declarative workflow. The skill is essential for teams implementing infrastructure automation at scale and maintaining consistency across provider implementations.
SDKv2 is the older Terraform provider development framework, while Plugin Framework is the newer, more type-safe approach. The Plugin Framework uses Go generics and provides better compile-time checking, cleaner schema definitions, and improved plan modifiers. New resources should use the Plugin Framework pattern.
Implement a resource when you need to manage the lifecycle (create, update, delete) of an infrastructure object. Implement a data source when you only need to read existing infrastructure state without managing it. Data sources are read-only and are used to reference existing resources or fetch information.
CRUD operations include Create (provision new resources), Read (refresh state from actual infrastructure), Update (modify existing resources), and Delete (destroy resources). Each operation must handle API interactions, state management, error handling, and ensure idempotency. The Read operation is particularly important as Terraform calls it frequently to detect drift.
State management involves correctly storing resource attributes in Terraform state after each operation. For imports, implement the Importer field with appropriate state context handling. The resource ID must be parseable to fetch the actual resource state, and the Read operation must populate all required attributes from the API response.
Resources should be organized within internal/service/<service>/ directories, with separate files for the resource implementation, acceptance tests, data sources, and finder functions. Documentation belongs in website/docs/r/ for resources and website/docs/d/ for data sources. The service_package_gen.go file handles auto-generated registration.
Quick Setup:
.claude/skills/Repository
hashicorp/agent-skills