Skip to content

srinivas-pradhan/vpc

Repository files navigation

Execute Terragrunt

Setup Provider

export AWS_ACCESS_KEY_ID=[YOUR_ACCESS_KEY_HERE]
export AWS_SECRET_ACCESS_KEY=[YOUR_SECRET_ACCESS_KEY_HERE]
export AWS_REGION=[YOUR_REGION_HERE]

Setup Terragrunt

terragrunt init

Apply Terragrunt

terragrunt apply -target=module.vpc -target=module.igw -target=module.eip
terragrunt apply -target=module.nat -target=module.routes

Terraform Docs

Install Terraform Docs

https://terraform-docs.io/user-guide/installation/

Generate Terraform Docs

terraform-docs .

Module Information / Usage

This module creates 3 Public facing subnets and multiple triads of private subnets as long as the VPC CIDR can accomodate the address space.

Please take a look at values.hcl for more information about module setup and usage.

The module uses cidrsubnets function to calculate subnets CIDRs. So please refer to that documentation in setting up new_bits for each subnet.

We can add more private subnets using this VPC module as shown in the below example.

subnets = [
            {
                name = "Public Subnet 1"
                new_bits = 4
                az = "a"
            },
            {
                name = "Public Subnet 2"
                new_bits = 4
                az = "b"
            },
            {
                name = "Public Subnet 3"
                new_bits = 4
                az = "c"
            },
            {
                name = "Web Subnet 1"
                new_bits = 4
                az = "a"
            },
            {
                name = "Web Subnet 2"
                new_bits = 4
                az = "b"
            },
            {
                name = "Web Subnet 3"
                new_bits = 4
                az = "c"
            },
            {
                name = "Data Subnet 1"
                new_bits = 4
                az = "a"
            },
            {
                name = "Data Subnet 2"
                new_bits = 4
                az = "b"
            },
            {
                name = "Data Subnet 3"
                new_bits = 4
                az = "c"
            },
                        {
                name = "Bastion Subnet 1"
                new_bits = 4
                az = "a"
            },
            {
                name = "Bastion Subnet 2"
                new_bits = 4
                az = "b"
            },
            {
                name = "Bastion Subnet 3"
                new_bits = 4
                az = "c"
            }
        ]

Module Documentation

Requirements

Name Version
aws 4.34.0

Providers

No providers.

Modules

Name Source Version
eip ./modules/eip n/a
igw ./modules/igw n/a
nat ./modules/nat n/a
routes ./modules/routes n/a
vpc ./modules/vpc n/a

Resources

No resources.

Inputs

Name Description Type Default Required
cidr_block VPC CIDR block string n/a yes
enable_dns_hostnames A boolean flag to enable/disable DNS hostnames in the VPC bool false no
enable_dns_support A boolean flag to enable/disable DNS support in the VPC. bool false no
region AWS region to deploy the resources. string n/a yes
subnets Subnet information necessary to create all the subnets. Please check cidrsubnets for more info on new_bits. The region variable is used to associate the desired AZ. Usage : join("",["us-east-1", "a"]). Example: values.hcl
list(object({
name = string
new_bits = number
az = string
}))
n/a yes
tags VPC Tags map(string) n/a yes
vpc_name VPC Name string "IaC VPC" no

Outputs

Name Description
eip Elastic IP address information
eip_map Elastic IP address information with subnet mapping
igw Internet Gateway Information.
nat_gw NAT Gateway information with the Subnet and EIP allocation ID.
private_subnet_ids Map of Private Subnet and associated subnet id created.private_subnet_ids = {"Web or Data Subnet 1" = { "subnet_id" = "subnet-xxxxxxx"}
public_route Public Route ID - Traffic to Internet Gateway
public_route_table Public Route Table ID.
public_subnet_ids Map of Public Subnet and associated subnet id created.public_subnet_ids = {"Public Subnet 1" = { "subnet_id" = "subnet-xxxxxxx"}
route_table_az1 Private Route Table ID - AZ1
route_table_az2 Private Route Table ID - AZ2
route_table_az3 Private Route Table ID - AZ3
subnets CIDR information associated with each subnet.
vpc_arn Amazon Resource Name (ARN) of VPC
vpc_id The ID of the VPC

About

VPC module for AWS resources

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages