In this blog, we are going to discuss the introduction to Terraform.

Terraform is one of the very popular Infrastructure tools, it is one of the products of HashiCorp which is an opensource software company based in San Francisco, California.

Basically, terraform allows you to define the infrastructure for a variety of the provider.
Eg: AWS, Azure, GCP, Digital Ocean and OpenStack etc…

It can manage more than Just Cloud providers, actually, it managing with an API, It uses a simple declare to programing language called HashiCorp configuration language auto deploy and manage Infrastructure using a CLI commands. HashiCorp also has an enterprise version of terraform.

Lets took an example for infrastructure as a code, as mention in below diagram we have two VPC with different subnets we need to do VPC peering, normally we are walking to Amazon management console click around web UI and create necessary resources and build infrastructure this is a very manual process.

Introduction to Terraform

Inside of doing the very manual way we can use IAC tools in this case we use Terraform which use HAsicorp language it also supports JSON syntax. We can do this activity in an automated way as mention in below vpc_peering.tf.

Sample Terraform Code: vpc_peering.tf

Provider “aws” {

region                                    = “ap-southeast-1”

shared_credentials_file     = “/user/sysadmin/.aws/credentials”

profile                                    = “terraform”

}

resource “aws_vpc” “vpc-prod-01” {

cidr_block = “10.10.0.0/16”

enable_dns_hostnames = true

tags = { Name = “vpc-prod-01”}

}

resource “aws_vpc” “vpc-prod-02” {

cidr_block = “192.168.0.0/16”

enable_dns_support = true

enable_dns_hostname = true

tags = { Name = “vpc-prod-02”}

}

Terraform providers >60 some of them are listed below:

Introduction to Terraform

Terraform has these three simple step:

  1. Write (Infrastructure as Code) – using lang called HashiCorp with a file extension “.tf“
  2. Plan (Preview Changes Before Applying)
  3. Create (Reproducible Infrastructure)

Use Terraform to manage Multi Clouds:

In your organization you have multiple projects which are using different Cloud Service like AWS, Azure or Google etc.. You can use Terraform for provisioning resources in more than one cloud.

Introduction to Terraform

This is the Introduction to Terraform, and it is a tool for Infrastructure automation (DevOps Tools).