Terraform Providers
Providers are plugins that allow Terraform to interact with cloud platforms, infrastructure services, SaaS platforms, and other APIs.
Key Topics
- • AWS
- • Microsoft Azure
- • Google Cloud
- • Kubernetes
Learn how Terraform providers connect to infrastructure platforms and how resources define the cloud and infrastructure components you want Terraform to manage.
Terraform Architecture
Configure Provider
Define Resources
Reference Dependencies
Create Execution Plan
Apply Infrastructure Changes
Introduction
Providers and resources are two of the most important concepts in Terraform. Providers allow Terraform to communicate with external infrastructure platforms and services.
Resources describe the actual infrastructure objects that Terraform should create, update, or manage. These can include virtual machines, networks, storage, databases, identity resources, and many other supported services.
Together, providers and resources allow you to define infrastructure using configuration files and manage that infrastructure through Infrastructure as Code.
Core Concepts
Understanding these concepts will help you create Terraform configurations and manage relationships between infrastructure components.
Providers are plugins that allow Terraform to interact with cloud platforms, infrastructure services, SaaS platforms, and other APIs.
Key Topics
Resources represent infrastructure objects that Terraform can create, update, and manage through a configured provider.
Key Topics
Arguments define the configuration and properties of a resource, such as region, instance type, names, network settings, and tags.
Key Topics
Terraform automatically analyzes references between resources to determine the correct order for creating and updating infrastructure.
Key Topics
Terraform Providers
Terraform uses providers to interact with APIs from cloud platforms, infrastructure services, container platforms, SaaS tools, and other supported technologies.
Before Terraform can manage a resource, the appropriate provider must be installed and configured for the infrastructure platform you want to use.
Provider Configuration Example
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
provider "aws" {
region = "us-east-1"
}Provider Types
Cloud providers allow Terraform to manage infrastructure on cloud platforms such as AWS, Azure, and Google Cloud.
Infrastructure providers can manage systems, platforms, networking components, containers, and other infrastructure services.
Some providers allow Terraform to manage software services and configuration through supported APIs.
Terraform also supports providers developed by technology vendors and the wider Terraform community.
Resource Configuration Example
resource "aws_instance" "web_server" {
ami = "ami-example"
instance_type = "t2.micro"
tags = {
Name = "web-server"
Environment = "development"
}
}Terraform Resources
A resource block describes an infrastructure object managed by Terraform. Each resource belongs to a provider and has a resource type supported by that provider.
Resource configurations can include arguments that define the desired properties of the infrastructure object.
Resource Examples
The exact resources available depend on the provider you are using, but Terraform can manage many different types of infrastructure components.
A resource can define a virtual machine or cloud compute instance with the required configuration.
Terraform resources can define virtual networks, subnets, routing components, firewalls, and other networking infrastructure.
Resources can manage object storage, block storage, databases, backups, and other data services.
Terraform can also manage supported Kubernetes infrastructure and resources through appropriate providers.
Infrastructure identity components such as users, roles, policies, and permissions can be managed through Terraform providers.
Providers can expose resources for managing supported application services and platform configurations.
Multiple Resources
Terraform configurations usually contain multiple resources that work together to create an infrastructure environment.
For example, a cloud application may require a virtual network, subnets, security rules, compute resources, storage, and other services.
Multiple Resource Example
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}Resource Dependency Example
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}
resource "aws_instance" "web" {
ami = "ami-example"
instance_type = "t2.micro"
subnet_id = aws_subnet.public.id
}Dependencies
Resources often depend on other resources. Terraform analyzes references between resources and uses those relationships to determine the correct order for infrastructure operations.
In the example, the subnet references the VPC ID, and the instance references the subnet. Terraform can use these relationships when building the execution plan.
Learning Roadmap
Start by understanding how providers connect Terraform to external platforms, then practice defining resources and building relationships between infrastructure components.
Learn how providers connect Terraform to cloud platforms and infrastructure APIs.
Define the provider requirements and configuration needed for your infrastructure environment.
Write resource blocks that describe the infrastructure objects Terraform should manage.
Connect resources by referencing attributes from one resource inside another configuration.
Understand how Terraform determines resource relationships and the order of infrastructure changes.
Combine providers and multiple resources to build complete Infrastructure as Code projects.
Best Practices
Use controlled provider version requirements to help maintain predictable Terraform environments.
Choose clear resource names that make your Terraform configuration easier to understand and maintain.
Separate infrastructure configuration logically as projects grow and become more complex.
Understand how resources reference each other and verify that infrastructure relationships are correctly defined.
Always inspect the Terraform plan before applying infrastructure changes.
Convert repeated infrastructure patterns into reusable modules as your Terraform projects grow.
Continue Learning
Next Step
Practice configuring providers, creating resources, connecting infrastructure components, and reviewing Terraform execution plans.