Terraform Module

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Write a 2 Module in Terraform. One Local Module, Second remote module. – Local Module Spec – in Ubuntu – Setup a webserver – Remote module – Setup VPC

resource "aws_instance" "avinash" {
  ami           = "ami-03d5c68bab01f3496"
  instance_type = "t2.micro"
  
  tags = {
    Name = "Avinash-Module"
  }
}

module "Avinash-Module" {
  source = "./modules/avi-module"
}

module "web-server" {
  source  = ".web-server/web-module"
  version = "0.0.10"
  
  cluster_name           = "webservers-stage"
  db_remote_state_bucket = "(BUCKET_NAME)"
  db_remote_state_key    = "stage/data-stores/mysql/terraform.tfstate"
  instance_type = "t2.micro"
  min_size      = 2
  max_size      = 2
}

module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name = "my-vpc"
  cidr = "10.0.0.0/16"

  azs             = ["us-west-2a", "us-west-2b", "us-west-2c"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

  enable_nat_gateway = true
  enable_vpn_gateway = true

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}