Skip to content

Terraform Providers

What are Terraform Providers?

Providers are plugins that Terraform uses to interact with cloud providers, SaaS providers, and other APIs. They define and manage resources for specific platforms or services.

Key Concepts

  1. Provider Configuration: How to set up and configure providers in your Terraform code.
  2. Provider Versioning: Managing provider versions for consistency and compatibility.
  3. Multiple Providers: Using multiple providers in a single Terraform configuration.
  4. Provider Authentication: Methods for authenticating with different providers.

Configuring Providers

Basic provider configuration:

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

Provider Versioning

Specify provider versions in your Terraform configuration:

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

Multiple Providers

Use aliases for multiple configurations of the same provider:

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

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

Common Providers

  1. AWS
  2. Azure
  3. Google Cloud Platform
  4. Kubernetes
  5. Docker

Remember to run terraform init after adding or changing providers to download the necessary plugins.