Skip to content

shamimice03/terraform-aws-vpc

Repository files navigation

Create AWS VPC using Terraform

Usage

module "vpc" {

    source = "shamimice03/vpc/aws"

    create = true

    vpc_name = "prod-vpc"
    cidr     = "192.168.0.0/16"

    azs                 = ["ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d"]
    public_subnet_cidr  = ["192.168.0.0/20", "192.168.16.0/20", "192.168.32.0/20"]
    private_subnet_cidr = ["192.168.48.0/20", "192.168.64.0/20", "192.168.80.0/20"]
    db_subnet_cidr      = ["192.168.96.0/20", "192.168.112.0/20", "192.168.128.0/20"]
    intra_subnet_cidr   = ["192.168.144.0/20", "192.168.160.0/20", "192.168.176.0/20"]

    enable_dns_hostnames      = true
    enable_dns_support        = true
    enable_single_nat_gateway = false

    tags = {
      "Team" = "platform-team"
      "Env"  = "prod"
    }
}

Requirements

Name Version
terraform >= 1.0.0
aws >= 5.0.0

Providers

Name Version
aws 5.72.1

Modules

No modules.

Resources

Name Type
aws_eip.single_eip resource
aws_internet_gateway.igw resource
aws_nat_gateway.single_nat_gateway resource
aws_route.private_route_table_route resource
aws_route.public_route_table_route resource
aws_route_table.db_route_table resource
aws_route_table.intra_route_table resource
aws_route_table.private_route_table resource
aws_route_table.public_route_table resource
aws_route_table_association.db_route_table_association resource
aws_route_table_association.intra_route_table_association resource
aws_route_table_association.private_route_table_association resource
aws_route_table_association.public_route_table_association resource
aws_subnet.db_subnet resource
aws_subnet.intra_subnet resource
aws_subnet.private resource
aws_subnet.public resource
aws_vpc.this_vpc resource

Inputs

Name Description Type Default Required
azs List of AZs list(any) [] no
cidr CIDR Block of the VPC string "" no
create Controls if VPC should be created or not bool true no
db_subnet_cidr Mapping AZ and DB subnets list(any) [] no
enable_dns_hostnames Should be true to enable DNS hostnames in the VPC bool false no
enable_dns_support Should be true to enable DNS support in the VPC bool true no
enable_single_nat_gateway Should be true to create NAT gateway for private subnets bool false no
intra_subnet_cidr Mapping AZ and Intra subnets list(any) [] no
private_subnet_cidr Mapping AZ and Private subnets list(any) [] no
public_subnet_cidr Mapping AZ and Public subnets list(any) [] no
tags A map of tags to add to all resources map(any) {} no
vpc_name Name of the vpc string "" no

Outputs

Name Description
database_route_table_id ID of the database route table
database_subnet_arn List of ARNs of database subnets
database_subnet_cidr List of CIDR blocks of database subnets
database_subnet_id List of IDs of database subnets
igw_arn The ARN of the Internet Gateway
igw_id The ID of the Internet Gateway
intra_route_table_id ID of the intra route table
intra_subnet_arn List of ARNs of intra subnets
intra_subnet_cidr List of CIDR blocks of intra subnets
intra_subnet_id List of IDs of intra subnets
nat_gateway_id The ID of the NAT Gateway
nat_gateway_public_ip The public IP address of the NAT Gateway
private_route_table_id ID of the private route table
private_subnet_arn List of ARNs of private subnets
private_subnet_cidr List of CIDR blocks of private subnets
private_subnet_id List of IDs of private subnets
public_route_table_id ID of the public route table
public_subnet_arn List of ARNs of public subnets
public_subnet_cidr List of CIDR blocks of public subnets
public_subnet_id List of IDs of public subnets
vpc_arn The ARN of the VPC
vpc_cidr_block The CIDR block of the VPC
vpc_id The ID of the VPC

Others: