DevOps Classroom notes 06/Nov/2025

Scenario – 1: Ntier application infra – AWS – cont

resource <Type> <LABEL> {
    arg1 = value1
    arg2 = valun2
    ..
    argn = valuen

}
  • Types in Hashicorp configuraion language
    • string x = '<value>'
    • number
    • boolean
    • list
    • set
    • map { name='qt', age = 10 }

Creating vpc as desired state in terraform

  • We have written the following block in a file network.tf
# vpc

resource "aws_vpc" "base" {
    cidr_block = "192.168.0.0/16"
    enable_dns_hostnames = true
    tags = {
      Name = "from-tf"
      Env = "Dev"
    }

}
  • Workflow
    • Lets format terraform template terraform fmt
    • Lets validate terraform template terraform validate
    • Lets create infra terraform apply
  • To view the attributes
    • resource: <type>.<label> in console

Now lets create subnets

  • Refer Here for subnet resource
  • To define order of creation we have two options
    • implicit dependency: see the example below
    • explicit depenency: this is acheived by depends_on
resource "aws_subnet" "web" {
  # implicit dependency
  vpc_id            = aws_vpc.base.id 
  availability_zone = "ap-south-1a"
  cidr_block        = "192.168.0.0/24"
  tags = {
    Name = "web"
    Env  = "Dev"
  }
  # explicit dependency
  depends_on = [ aws_vpc.base ]

}
  • Refer Here for the changes done to create vpc with 3 subnets
  • Lets create internet gateway and two route tables Refer Here for changes
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%