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%
Add provider-level configuration with environment variable fallback to the HashiCorp scaffold.
git clone https://github.com/hashicorp/terraform-provider-scaffolding-framework.git .
git checkout 3f9b7d20f49724d61ffaa28f5812c347b6a3e4a1
go mod tidyModify the existing provider in provider.go to accept configuration:
endpoint attribute (Optional, String) with a Description. This is the base URL for an API.api_key attribute (Optional, Sensitive, String) with a Description. This is an authentication token.Implement the Configure method so that:
req.Config.Getendpoint is null or unknown, fall back to the EXAMPLE_ENDPOINT environment variableapi_key is null or unknown, fall back to the EXAMPLE_API_KEY environment variableendpoint is still empty after checking the environment variable, add an error diagnostic (it is required)req.ProviderData in their Configure methodsUpdate the existing example_resource to:
Configure method that retrieves the provider data from req.ProviderDatareq.ProviderData is nil (return early, this happens during plan)Write an acceptance test that:
Ensure the project builds with go build ./....