Terraform & AWS foundation

Screenshot (43).png


AWS Provider & Terraform init:

Terraform Registry

provider.tf file:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region                  = "ap-south-1"
  shared_credentials_file = "~/.aws/credentials"
  profile                 = "tf_is_tf"
}

Run: $ terraform init


AWS VPC:

Terraform Registry

main.tf file:

resource "aws_vpc" "tf_vpc" {
  cidr_block           = "10.123.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = {
    Name = "dev"
  }
}

Run: $ terraform plan

Run: $ terraform apply


Terraform State:

State | Terraform by HashiCorp

The primary purpose of Terraform state is to store bindings between objects in a remote system and resource instances declared in your configuration.