0Pricing
DevOps Bootcamp · Lesson

Building Custom Providers

Extend Terraform beyond existing integrations by understanding how providers work and authoring a custom provider with the Terraform Plugin Framework.

Building Custom Providers is a free DevOps Bootcamp lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

When Existing Providers Fall Short

The registry covers most platforms, but enterprises often run internal APIs with no provider. A custom provider lets Terraform manage those resources with the same plan/apply lifecycle.

How Providers Work

A provider is a separate plugin binary that Terraform launches and talks to over gRPC. The plugin translates Terraform's CRUD operations into API calls against the target system.

The Plugin Framework

HashiCorp's modern Terraform Plugin Framework (Go) is the recommended way to build providers, replacing the older SDKv2. Providers are written in Go.

import (
  "github.com/hashicorp/terraform-plugin-framework/provider"
)

Defining the Provider

The provider type declares its name and the resources and data sources it offers.

type widgetProvider struct{}

func (p *widgetProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) {
  resp.TypeName = "widget"
}

The Resource Schema

Each resource declares a schema of attributes with types and metadata. This is what users set in their HCL.

resp.Schema = schema.Schema{
  Attributes: map[string]schema.Attribute{
    "name": schema.StringAttribute{Required: true},
    "id":   schema.StringAttribute{Computed: true},
  },
}

Implementing CRUD

A resource implements Create, Read, Update, and Delete. Each method calls your API and writes the result back into Terraform state.

func (r *widgetResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
  // call API, then save state
}

Read Keeps State Honest

The Read method refreshes state from the real API. If the remote resource is gone, you remove it from state so Terraform plans to recreate it.

Acceptance Testing

Providers use acceptance tests that run real plan/apply cycles against a test environment, gated behind an environment variable so they do not run accidentally.

TF_ACC=1 go test ./... -v

Local Development Override

To test a provider before publishing, use a dev override in your CLI config so Terraform loads your local binary instead of downloading from a registry.

provider_installation {
  dev_overrides {
    "acme/widget" = "/home/dev/go/bin"
  }
  direct {}
}

Publishing the Provider

Publish to the registry by tagging a release and signing the binaries with a GPG key. Consumers then declare it in required_providers.

terraform {
  required_providers {
    widget = {
      source  = "acme/widget"
      version = "~> 1.0"
    }
  }
}

Maintenance Considerations

A provider is a long-term commitment: API changes, version compatibility, and documentation all need upkeep. For one-off needs, the external data source or a script may be simpler than a full provider.

Quick Check

Test your custom provider knowledge.

Recap: Extending Terraform

You learned to build custom providers:

  • Providers are Go plugins talking gRPC to core.
  • The Plugin Framework defines schemas and CRUD methods.
  • Dev overrides enable local testing; acceptance tests verify behavior.
  • Publishing requires tags and signed binaries.

Frequently asked questions

Is the “Building Custom Providers” lesson free?

Yes — the full text of “Building Custom Providers” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

What will I learn in “Building Custom Providers”?

Extend Terraform beyond existing integrations by understanding how providers work and authoring a custom provider with the Terraform Plugin Framework. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Building Custom Providers” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Multi-Cloud and Hybrid Cloud Patterns
  2. Sentinel Policies for Governance
  3. Terraform Cloud and Enterprise
  4. Building Custom Providers
← Back to DevOps Bootcamp