
Terraform is an Infrastructure as Code (IAC) tool that allows users to define and provision infrastructure resources using a simple, easy-to-understand configuration language. It is used to create, manage, and update infrastructure resources in a consistent and predictable way.
It is cloud-agnostic, which means that it can be used to provision and manage infrastructure resources across multiple cloud providers and on-premises environments. This is achieved through the use of providers, which are responsible for talking to a specific service or infrastructure, such as AWS, Azure, or GCP.
Each provider has its own set of resources and data sources that can be used to provision and manage infrastructure resources. For example, the AWS provider includes resources for provisioning EC2 instances, RDS databases, and S3 buckets, while the Azure provider includes resources for provisioning virtual machines, storage accounts, and virtual networks.
When defining resources in Terraform, users specify which provider they want to use for that resource. This allows users to use the same Terraform configuration to provision resources across different cloud providers and on-premises environments.
In addition to cloud providers, Terraform also supports other types of providers such as DNS, Databases, LoadBalancer and much more. This allows users to manage all their infrastructure resources, including networking, DNS, and load balancing, using the same tool and configuration.
Terraform’s cloud-agnostic nature allows organizations to standardize their infrastructure provisioning process across different environments and to easily move resources between different cloud providers. This increases the flexibility and portability of infrastructure, making it easier to manage and update resources in a consistent and predictable way.
Advantage of Terraform is its ability to manage the full lifecycle of infrastructure resources, from initial creation to updates and deletion. This eliminates the need for manual provisioning and management of resources, reducing the risk of human error and increasing the speed and consistency of infrastructure provisioning.
Terraform also supports version control, which allows users to track changes to their infrastructure over time and roll back to previous versions if necessary. This helps to ensure that infrastructure is always in a known, working state and can be easily recreated if necessary.
In addition, Terraform has a large and active community, which provides a wealth of resources and support. This includes a library of pre-built modules, which can be used to quickly provision common types of resources, such as load balancers and databases.
Overall, Terraform is a powerful IAC tool that allows organizations to provision and manage infrastructure resources in a consistent and predictable way. Its ability to manage resources across multiple cloud providers and on-premises environments, full lifecycle management, version control, and active community make it a valuable tool for organizations of all sizes.
TERRAFORM CONFIGURATION FILES

In Terraform, there are several different types of files that can be used to define and provision infrastructure resources. Written in the HashiCorp Configuration Language (HCL), it is a domain-specific configuration language created by HashiCorp, the company behind Terraform. The list of files include:
Main Terraform Configuration files : These files use the .tf file extension and contain the main Terraform configuration for provisioning infrastructure resources. They define the resources that will be created, as well as any associated settings and variables.
Terraform Variable files : These files use the .tfvars file extension and contain variable definitions that can be used in the main Terraform configuration files. These variables can be used to define values that will be used in multiple places in the configuration, making it easier to manage and update resources.
Terraform State files : These files use the .tfstate file extension and contain information about the current state of the infrastructure resources that have been provisioned. Terraform uses this information to determine what changes need to be made to the infrastructure in order to match the desired state defined in the configuration files.
Terraform Module files : These files use the .tf file extension and define a set of resources that can be reused across multiple Terraform configurations. Modules can be thought of as reusable, self-contained units of infrastructure that can be easily managed and shared between teams.
Terraform Provider files : These files use the .tf file extension and define the configuration for a specific Terraform provider. A provider is responsible for talking to a specific service or infrastructure, such as AWS, Azure, or GCP.
Terraform Backend files : These files use the .tf file extension and define the configuration for the backend, which is responsible for storing the state file. The backend is a separate component that allows Terraform to store state in shared storage like S3, GCS, Azure Blob, etc.
All of these files work together to define and provision infrastructure resources using Terraform, making it easy to manage and update resources in a consistent and predictable way.
SOME BASIC HANDS-ON !

A simple proof of concept for using Terraform to provision an Amazon Web Services (AWS) EC2 instance:
Prerequisites
- AWS account
- AWS account access key and secret key (if unsure how to do this, follow the guide here)
Lets do this…
- First, you’ll need to have Terraform installed on your machine. You can download the latest version from the Terraform website.
- Next, create a new directory for your Terraform project, and within that directory, create a file named
main.tf. This file will contain the Terraform configuration for your AWS resources. - In your
main.tffile, you’ll need to specify the AWS provider and configure your AWS access keys. This can be done as follows:
provider "aws" {
region = "us-west-2"
access_key = "YOUR_ACCESS_KEY"
secret_key = "YOUR_SECRET_KEY"
}
4. To create an EC2 instance, you can use the aws_instance resource. In your main.tf file, add the following resource block:
resource "aws_instance" "example" {
ami = "ami-0ff8a91507f77f867"
instance_type = "t2.micro"
}
- Now you can initialize your Terraform project by running the command
terraform initin your project directory. - To see what changes Terraform will make to your infrastructure, you can run the command
terraform plan - If the plan looks good, you can apply the changes by running the command
terraform apply. This will create an EC2 instance in the specified region using the specified AMI and instance type. - To destroy the EC2 instance, you can run the command
terraform destroy.
Note: Above example is a basic one and it doesn’t cover all the aspects of creating an EC2 instance, it is just a starting point for you to understand the basic concept of Terraform and how it can be used to provision resources in AWS.
This is a simple example of using Terraform to provision an AWS EC2 instance. You can add more resources, such as security groups, load balancers, and databases, to your configuration to create more complex infrastructure. Additionally, you can use variables, modules, and other Terraform features to further automate and manage your infrastructure.
IF YOU HAVE MADE IT THIS FAR …
Do checkout below for extra knowledge (wink wink):
- terraform fmt : a command in Terraform that automatically formats and indent the code of your Terraform configuration files. It can be used to ensure that your Terraform code is consistent, readable, and easy to maintain. More info can be found here.
- terraform console : a command in Terraform that allows you to interact with the Terraform state and evaluate expressions in a live environment. It allows you to test and debug your Terraform configurations and see the results of your expressions in real-time, without having to make changes to your infrastructure. When you run the
terraform consolecommand, it will start an interactive console in your terminal. You can then enter Terraform expressions, such as variable references and function calls, and see the results. For example, let’s say you have the following Terraform configuration:
variable "example" {
default = "Hello, World!"
}
You can run terraform console and then enter the following expression in the console:
> example
"Hello, World!"
It also allows you to access and query the current state of resources provisioned by Terraform, you can use the terraform state command in the console to retrieve the values of resources in the state.
Hopefully, this article sheds some light on Terraform and helps readers understand the basics of IAC Terraform. If you have some questions around terraform, I will try to answer them best to my knowledge.