DevOps Classroom notes 31/Dec/2024

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:
      • This works only on AWS
    • ARM Templates
      • This works only on Azure
    • 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
    Preview
  • Resources
    Preview

Terminology

  • Arguments:
    • Refers to an input
  • Attribute
    • Refers to an output

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.

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube