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 a provider-defined function to the HashiCorp scaffold that parses a composite ID string.
git clone https://github.com/hashicorp/terraform-provider-scaffolding-framework.git .
git checkout 3f9b7d20f49724d61ffaa28f5812c347b6a3e4a1
go mod tidyCreate a new file for a parse_id provider-defined function. The function takes a composite ID string in the format "type:name" and returns just the name portion.
Implement the function.Function interface:
parse_idinput parameter (String) — the composite ID to parse (e.g. "resource:my-thing")req.Arguments.Get":"function.NewArgumentFuncErrorresp.Result.SetRegister the function in the provider by implementing the Functions method on the provider (implementing provider.ProviderWithFunctions).
Write tests for the function:
function.RunRequest and calls Run:
"resource:my-thing" returns "my-thing""nocolon" returns a function erroroutput "test" { value = provider::scaffolding::parse_id("resource:my-thing") } and verifies the output valueEnsure the project builds with go build ./....