Content ITV PRO
This is Itvedant Content department
Learning Outcome
5
Understand how Providers, Resources, Variables and Outputs work together in Terraform
4
Use Outputs to display useful information after deployment
3
Use Variables to make Terraform configurations flexible
2
Identify and define Resources in Terraform configurations
1
Understand the role of Providers in Terraform
Imagine you are ordering furniture for a new office
Imagine you are ordering furniture for a new office
The store you buy furniture from is like the Provider
The items you purchase (tables, chairs, cabinets) are the Resources
Provider
Resources
Imagine you are ordering furniture for a new office
The custom options like color or size are like Variables
The final receipt showing what you purchased is similar to Outputs
Variables
Outputs
Transition from Analogy to Technical Concept
In Terraform, infrastructure is created using similar building blocks
These building blocks are Providers, Resources, Variables and Outputs
Providers
Providers
Providers
Providers
What is a Provider ?
A Provider is a plugin that allows Terraform to interact with a specific platform or service.
It acts as a bridge between Terraform and external services
Examples of services Terraform can connect to:
Amazon Web Services
Microsoft Azure
Google Cloud Platform
Kubernetes
GitHub
Why Providers are Needed
Terraform itself cannot directly communicate with cloud platforms
Providers help Terraform:
Create resources
Update resources
Delete resources
Manage infrastructure services
Example Provider Configuration
provider "aws" {
region = "us-east-1"
}
This configuration tells Terraform:
Use the AWS provider and deploy resources in the us-east-1 region
What is a Resource ?
A Resource represents an infrastructure component that Terraform manages.
Resources can include:
Virtual machines
Networks
Databases
Storage buckets
Load balancers
Each resource block defines what infrastructure should be created
What is a Resource ?
resource "aws_instance" "web_server" {
ami = "ami-123456"
instance_type = "t2.micro"
}
Explanation:
aws_instance → Type of resource
web_server → Resource name
Configuration inside the block defines how the resource should be created
This example creates an EC2 instance in AWS.
What are Variables ?
Variables allow you to parameterize Terraform configurations
Instead of hardcoding values, you can use variables so that the same configuration can be reused
Variables help in:
Making code reusable
Improving flexibility
What are Variables ?
Example:Different instance types for:
Development
Testing
Production
Example Variable
variable "instance_type" {
default = "t2.micro"
}
Using the variable in a resource:
instance_type = var.instance_type
This means Terraform will use the value stored in the variable
What are Outputs ?
Outputs allow Terraform to display useful information after infrastructure is created
They are commonly used to show:
Public IP addresses
DNS names
Resource IDs
Connection details
Example Output
output "instance_ip" {
value = aws_instance.web_server.public_ip
}
After Terraform finishes execution, it will display the public IP of the created server
How These Components Work Together
Terraform infrastructure typically works like this:
Provider
Connects Terraform to a cloud platform.
Variables
Define configurable values.
Resources
Define what infrastructure should be created.
Outputs
Display useful information after deployment.
How These Components Work Together
Example Terraform Configuration
provider "aws" {
region = "us-east-1"
}
variable "instance_type" {
default = "t2.micro"
}
resource "aws_instance" "web_server" {
ami = "ami-123456"
instance_type = var.instance_type
}
output "instance_ip" {
value = aws_instance.web_server.public_ip
}
This configuration:
Connects to AWS
Uses a variable for instance type
Creates an EC2 instance
Displays the instance public IP
Core Concepts (.....Slide N-3)
Key Points
Important Terraform Files
Common Terraform file extensions:
.tf → Terraform configuration files
.tfvars → Variable values
.tfstate → Terraform state file
Summary
5
Together, these components form the core building blocks of Terraform configurations
4
Outputs display useful information after deployment
3
Variables make Terraform configurations flexible and reusable
2
Resources define infrastructure components Terraform will manage
1
Providers allow Terraform to interact with cloud platforms
Quiz
Which Terraform component acts as a bridge between Terraform and a cloud platform ?
A. Resource
B. Provider
C. Variable
D. Output
Quiz
Which Terraform component acts as a bridge between Terraform and a cloud platform ?
A. Resource
B. Provider
C. Variable
D. Output
Quiz-Answer
Which platform is mainly used for professional networking and B2B marketing ?
A. Facebook
B. Instagram
C. LinkedIn
D. Snapchat
By Content ITV