Free — no signup required

Provider Project Structure

1 min read

Laying the Foundation

Before writing any resource logic, you need to understand how a provider project is organized. A well-structured provider follows a consistent layout that the Terraform ecosystem expects: a minimal entry point that registers the provider with Terraform's plugin protocol, an internal package holding the provider's top-level struct and one file per resource and per data source, an examples directory used to generate documentation, and the standard Go module scaffolding.

The entry point itself does almost nothing beyond wiring: it declares the provider's registry address (which must match the source string users reference in their required_providers block) and hands control to the framework's serve function. provider.go defines the top-level provider struct, its configuration schema (e.g., API endpoint, credentials), and the list of resources and data sources it exposes:

func (p *xyzProvider) Resources(ctx context.Context) []func() resource.Resource {
    return []func() resource.Resource{
        NewServerResource,
    }
}

The Address field in main.go is critical — it must match the source in the user's required_providers block. For local development, you override this with a dev_overrides block in ~/.terraformrc.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free