InfraProvisioning with Terraform
- Infra Provisioning helps in automating the infra creation, To do this we have various apporaches
- scripts (use awscli/azurecli/python)
- procedural (how it has to be done)
- focus is on steps
- Infrastruce as Code (IaC)
- Declarative (what is needed)
- Focus is on desired state
- Popular IaC Tools
- Cloud formation:
- ARM Templates
- Bicep (Azure)
- Terraform:
- This works with almost all clouds and even hypervisors like vmware
- OpenTofu
- This is a fork of terraform and will remain opensource
Terraform
- This is a project by Hashicorp
- Terraform is developed in Golang
- Terraform uses a language called as HCL (Hashicorp Configuration Language)
Terraform components
- Template
- Providers

- Resources

Terminology
Installing Terraform
Hello terraform
- Create a new folder
- Create a new file called as main.tf in it
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.82.2"
}
}
}
provider "aws" {
region = "ap-south-1"
}
resource "aws_vpc" "net" {
cidr_block = "10.10.0.0/16"
tags = {
Name = "hello-tf"
}
}
- Now from your terminal cd into this folder and execute
terraform init
terraform apply
- We can connect to multiple clouds from same template.
Like this:
Like Loading...