The module creates a set of resources and configures VPC following a canonical scheme for secure multi-AZ AWS VPC.
The setup includes public and private subnets with NAT gateways and Internet Gateway in specified Avalability Zone(s).

Log in to Corewide IaC registry

Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:

 shellterraform login solutions.corewide.com
Provision instructions

Initialize mandatory providers:

Copy and paste into your Terraform configuration and insert the variables:

 hclmodule "tf_aws_vpc" {
  source  = "solutions.corewide.com/aws/tf-aws-vpc/aws"
  version = "~> 4.0.0"

  # specify module inputs here or try one of the examples below
  ...
}

Initialize the setup:

 shellterraform init
Define update strategy

Corewide DevOps team strictly follows Semantic Versioning Specification to provide our clients with products that have predictable upgrades between versions. We recommend pinning patch versions of our modules using pessimistic constraint operator (~>) to prevent breaking changes during upgrades.

To get new features during the upgrades (without breaking compatibility), use ~> 4.0 and run terraform init -upgrade

For the safest setup, use strict pinning with version = "4.0.0"

The module creates a set of resources and configures VPC following a canonical scheme for secure multi-AZ AWS VPC.
The setup includes public and private subnets with NAT gateways and Internet Gateway in specified Avalability Zone(s).

Canonical VPC setup with public and private segments of the network:

 hclmodule "vpc" {
  source  = "solutions.corewide.com/aws/tf-aws-vpc/aws"
  version = "~> 4.0"

  name_prefix = "foo"
  cidr_block  = "20.20.0.0/16"

  subnets = {
    private-1 = {
      availability_zone         = "us-east-1b"
      private_subnet_cidr_block = "20.20.6.0/24"
      #  Setup outgoing access to the Internet with NAT gateway
      nat_via = "public-1"
    },
    public-1 = {
      availability_zone        = "us-east-1b"
      public_subnet_cidr_block = "20.20.5.0/24"
    },
  }

  tags = {
    Project = "bar"
  }
}

Non-canonical VPC setup:

 hclmodule "vpc" {
  source  = "solutions.corewide.com/aws/tf-aws-vpc/aws"
  version = "~> 4.0"

  name_prefix = "foo"
  cidr_block  = "20.20.0.0/16"

  subnets = {
    private-1 = {
      availability_zone         = "us-east-1b"
      private_subnet_cidr_block = "20.20.6.0/24"
    },
    public-1 = {
      availability_zone        = "us-east-1b"
      public_subnet_cidr_block = "20.20.5.0/24"
    },
  }

  tags = {
    Project = "bar"
  }
}
Variable Description Type Default Required Sensitive
cidr_block The CIDR block for the VPC string yes no
name_prefix Naming prefix for all the resources created by the module string yes no
subnets Specific definitions for the subnets creation. Map keys are used as subnet names and values with further defined elements map(object) yes no
subnets[<key>] Subnet name string yes no
tags Tag(s) that must be assigned to resources map(string) yes no
dns_hostnames_enabled Enable/disable DNS hostnames for VPC bool true no no
enable_dns_hostnames Enable/disable DNS hostnames for VPC (Deprecated in favour of \"dns_hostnames_enabled\" and will be deleted in the next few releases) bool no no
private_subnet_destination_cidr_block Allowed destination CIDR block for access from the public VPC segment string 0.0.0.0/0 no no
public_subnet_destination_cidr_block Allowed destination CIDR block for access from the public VPC segment string 0.0.0.0/0 no no
subnets[<key>].availability_zone Availability zone of the subnet string yes no
subnets[<key>].enable_auto_assigning_ips Defines that instances launched into the public subnet should be assigned a public IP address bool true no no
subnets[<key>].nat_via Name of public subnet to create NAT GW in. Private network will use it for outgoing Internet traffic string no no
subnets[<key>].private_subnet_cidr_block The IPv4 CIDR block for the private subnet string no no
subnets[<key>].public_subnet_cidr_block The IPv4 CIDR block for the public subnet string no no
Output Description Type Sensitive
private_subnets Contains attributes of private VPC segment resource no
public_subnets Contains attributes of public VPC segment resource no
vpc Contains attributes of aws_vpc resource resource no
Dependency Version Kind
terraform >= 1.3 CLI
hashicorp/aws ~> 5.0 provider

Not sure where to start?
Let's find your perfect match.