DevOps Classroom notes 09/Jun/2025

Terraform Modules

  • Modules are reusable terraform templates
  • modules will not have providers and can be called by multiple templates
    Preview
  • Modules can be present in (module sources)
    • local folder
    • git
    • Terraform Cloud
  • To call a module we use a module block
module <name> {
    source = "<module-source>"
    arg1 = value1
    arg2 = value2
    ...
    argn = valuen
}
  • To create a module, just create a new folder with some name, ensure you have
    • resources
    • variables (inputs/arguments)
    • outputs (outputs/attributes)
  • Added module for security group locally
  • Refer Here for modules for vpc, security group
  • Terraform also has a registry where lots of modules are already available
  • Refer Here for a community module on vpc and try creating vpc with this module
module "vpc" {
  source = "terraform-aws-modules/vpc/aws"
  version = "5.21.0"

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

  azs             = ["ap-south-1a", "ap-south-1b"]
  private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
  public_subnets  = ["10.0.101.0/24", "10.0.102.0/24"]

  enable_nat_gateway = false
  enable_vpn_gateway = false

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

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
Animated Social Media Icons by Acurax Responsive Web Designing Company

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