Skip to main content
RunBook Academy

TerraformVI · Providers and the Provider EcosystemProviders

Providers: The Plugin Architecture

Foundation⏱ ~14 min🧪 Lab requiredbashterraform

What you'll learn

  • Configure a provider for a real platform
  • Distinguish provider source from provider version
  • Recognise the difference between required_providers and provider blocks
  • Use multiple provider instances for multi-account architectures

Prerequisites

Verified against Terraform CLI 1.9.x · OpenTofu 1.7.x · HCL 2.0 · bpg/proxmox provider 0.66+ · hashicorp/local provider 2.5+ · hashicorp/null provider 3.2+ · hashicorp/random provider 3.6+ · hashicorp/http provider 3.4+ · Ubuntu 24.04 LTS · Debian 12 (Bookworm) · 2026-08-12

Not yet marked complete on this device.

A provider is a plugin that translates Terraform resource operations into API calls against a specific platform. The provider is the bridge between the configuration and the real world. This lesson teaches the provider architecture, the configuration, and the multi-provider patterns.

What a provider does

A provider contains:

  • The resource schema (e.g. aws_instance has ami, instance_type, tags, etc.).
  • The provider API client (HTTP client, auth handling, retry logic).
  • The CRUD operations (create, read, update, delete) for each resource type.
  • The replacement rules (which attribute changes force replacement).
  • The data source implementations.

The provider is a stand-alone process. The Terraform CLI communicates with the provider over an internal RPC protocol. The provider is what owns the knowledge of the platforms API.

Declaring a provider

The required_providers block declares which providers the configuration uses:

terraform {
  required_version = ">= 1.9.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

The fields:

  • source — the registry address. HashiCorps registry is registry.terraform.io. The format is <NAMESPACE>/<TYPE>.
  • version — the version constraint. The ~> 5.0 means “compatible release” (5.0.x, 5.1.x, 5.2.x, but not 6.0.x).

The provider is downloaded by terraform init from the registry.

Configuring a provider

The provider block configures the provider:

provider "aws" {
  region = "us-east-1"

  default_tags {
    tags = {
      Environment = "production"
      ManagedBy   = "terraform"
    }
  }
}

The fields are provider-specific. The provider documentation is the source of truth.

Multi-provider configurations

A configuration can use multiple providers:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

provider "azurerm" {
  features {}
}

The resources use the type prefix to disambiguate:

resource "aws_instance" "web" {
  ami = "ami-0e1bed4f"
}

resource "azurerm_virtual_machine" "web" {
  # ...
}

Provider aliases

A provider alias is a configuration that allows multiple instances of the same provider:

provider "aws" {
  region = "us-east-1"
}

provider "aws" {
  alias  = "west"
  region = "us-west-2"
}

resource "aws_instance" "web_east" {
  provider = aws
  ami = "ami-0e1bed4f"
}

resource "aws_instance" "web_west" {
  provider = aws.west
  ami = "ami-0e1bed4f"
}

The alias is used to address the specific provider instance.

The legitimate use cases:

  • Multi-region deployments.
  • Multi-account deployments.
  • Multi-role deployments (one for the operator, one for the application).

Provider authentication

The provider authenticates against the platform. The authentication method is provider-specific:

  • AWS — IAM roles, environment variables, or AWS_PROFILE.
  • Azure — service principals, managed identities, or environment variables.
  • GCP — service accounts, workload identity, or environment variables.
  • GitHub — personal access tokens, GitHub App tokens, or GitHub Actions tokens.

The course has a dedicated lesson on provider authentication (Part XVII).

Provider versions

The required_providers block pins the version:

required_providers {
  aws = {
    source  = "hashicorp/aws"
    version = "~> 5.0"
  }
}

The version constraint is the floor. The lockfile records the resolved version.

The lockfile is the source of truth for the actual provider version. The configuration is the source of truth for the constraint.

Provider blocks vs required_providers

The two have different roles:

BlockPurpose
required_providersDeclares which providers the configuration uses. Always at the top of the configuration.
providerConfigures a provider instance. May be repeated for aliases.

The provider block may be omitted if the defaults are acceptable. The required_providers block is required for any provider that is not in the default namespace.

What comes next

The next lesson is provider version constraints — the production control for provider supply chain.

Verification

Knowledge check · 7 questions

  1. Q1. What is the role of the provider source address?

  2. Q2. What is the role of provider aliases?

  3. Q3. You can mix unaliased and aliased providers in the same configuration.

  4. Q4. What is the role of provider authentication?

  5. Q5. Which of the following are provider failure modes? (Select all that apply.)

  6. Q6. What is the role of required_providers?

  7. Q7. A team upgrades a provider and the plan now fails. What is the most likely cause?

Passing score: 75%. Answers are checked in this browser.