Providers
Providers are the plugins that Terraform uses to interact with cloud platforms and services. Each provider offers a set of resource types and data sources.
What Is a Provider?
A provider is responsible for understanding API interactions and exposing resources. For example, the AWS provider knows how to create EC2 instances, S3 buckets, and IAM roles.
Providers make Terraform cloud‑agnostic – you can use the same workflow for any platform.
Basic Provider Configuration
In your Terraform configuration file (e.g.,
main.tf), you declare providers:terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-east-1"
}Common Providers
- hashicorp/aws – Amazon Web Services
- hashicorp/azurerm – Microsoft Azure
- hashicorp/google – Google Cloud Platform
- hashicorp/kubernetes – Kubernetes
- hashicorp/random – Generate random strings/IDs
- hashicorp/tls – Generate TLS certificates
Provider Initialization
After writing the configuration, run
terraform init. Terraform downloads the provider plugins from the Terraform Registry into a .terraform directory.Provider Versioning
Specify version constraints to avoid unexpected breaking changes. Common operators:
>= 5.0– at least version 5.0~> 5.0– any 5.x version but not 6.05.0.0– exact version
Provider Configuration Arguments
Each provider accepts arguments like region, endpoint, or authentication details. For security, avoid hard‑coding secrets; use environment variables or a secrets manager. For AWS, you can set
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.Two Minute Drill
- Providers are plugins that interact with APIs.
- Declare required providers in
terraformblock. - Run
terraform initto download providers. - Pin provider versions to avoid unexpected changes.
Need more clarification?
Drop us an email at career@quipoinfotech.com
