Module 2: Terraform Fundamentals

Lesson 2.1: How Terraform Uses Providers

Plain language

A provider is a plugin that teaches Terraform how to manage one platform or service. Each provider defines resource types (things to create and manage, such as random_pet) and data sources (things to read, such as aws_ami). Terraform core handles the language, graph, plan, and state. The provider handles the API calls.

Under the hood

  1. Discovery. Terraform reads required_providers in every module of your configuration.
  2. Installation. terraform init downloads each provider binary, by default from the public Terraform Registry at registry.terraform.io, into .terraform/providers/.
  3. Execution. During plan and apply, core starts each provider as a separate process and talks to it over an RPC plugin protocol. It asks the provider for schemas, refreshes objects, plans diffs, and applies changes.

Source addresses use the form [HOSTNAME/]NAMESPACE/TYPE:

You write Full address
hashicorp/random registry.terraform.io/hashicorp/random
kreuzwerker/docker registry.terraform.io/kreuzwerker/docker
app.terraform.io/acme/internal A provider in an HCP Terraform private registry

Local names. The key you use inside required_providers (for example random = {...}) is the provider's local name. Resource types are matched to providers by their prefix: random_pet belongs to the provider whose local name is random.

Registry tiers:

Tier Who publishes it
Official Owned and maintained by HashiCorp (the hashicorp/ namespace)
Partner Third-party technology companies that have joined HashiCorp's partner program
Community Individuals and groups

You can find binaries in the Terraform Registry or in a private registry. HCP Terraform supports a private registry for both providers and modules.