Skip to content
main.tf 1.26 KiB
Newer Older
Michael Kennedy's avatar
Michael Kennedy committed
#
# Create the VPC 
# using directions from https://clouddocs.f5.com/cloud/public/v1/aws/AWS_multiNIC.html
#
module "vpc" {
  source = "terraform-aws-modules/vpc/aws"

  name                 = format("%s-vpc-%s", var.tags.prefix, var.tags.random)
  cidr                 = var.aws_vpc.cidr
Michael Kennedy's avatar
Michael Kennedy committed
  enable_dns_hostnames = true
  enable_dns_support   = true

  # azs = var.aws_vpc.azs
Michael Kennedy's avatar
Michael Kennedy committed

  # vpc public subnet used for external interface
  public_subnets = [for num in range(length(var.aws_vpc.azs)) :
    cidrsubnet(var.aws_vpc.cidr, 8, num + var.external_subnet_offset)
Michael Kennedy's avatar
Michael Kennedy committed
  ]

  # vpc private subnet used for internal 
  private_subnets = [
    for num in range(length(var.aws_vpc.azs)) :
    cidrsubnet(var.aws_vpc.cidr, 8, num + var.internal_subnet_offset)
Michael Kennedy's avatar
Michael Kennedy committed
  ]

  enable_nat_gateway = true

  # using the database subnet method since it allows a public route
  database_subnets = [
    for num in range(length(var.aws_vpc.azs)) :
    cidrsubnet(var.aws_vpc.cidr, 8, num + var.management_subnet_offset)
Michael Kennedy's avatar
Michael Kennedy committed
  ]
  create_database_subnet_group           = true
  create_database_subnet_route_table     = true
  create_database_internet_gateway_route = true

  tags = {
    Name        = format("%s-vpc-%s", var.tags.prefix, var.tags.random)
Michael Kennedy's avatar
Michael Kennedy committed
    Terraform   = "true"
Michael Kennedy's avatar
Michael Kennedy committed
  }
Michael Kennedy's avatar
Michael Kennedy committed
}