This is a terraform module that brings up a full AWS VPC with all the bells and whistles
This module helps deploy the following AWS resources
- A primary VPC - the star of the show - with a modified RFC1918 IP space [^ref1] in compliance with AWS restrictions
- An Internet gatway associated with the VPC
- A NAT gateway for IPv4 and IPv6 egress traffic
- An egress-only internet gateway for outgoing IPv6 traffic
- A Public and a Private subnet with associated route tables containing appropriate routes
- Prefix lists to maintain admin IP addresses to use in Security Group whitelists
Planned to be implemented:
- [TODO] VPC Endpoints for S3 and other services
- Import the module in your root module:
module "vpc" {
source = "git::https://gitlab.com/eternaltyro/terraform-aws-vpc.git"
...
key = var.value
}
If you wish to use SSH to connect to git, then something like this will help:
module "vpc" {
source = "git::ssh://[email protected]/eternaltyro/terraform-aws-vpc.git"
}
- Write a provider block with the official AWS provider:
terraform {
required_version = ">= 1.4.0"
requried_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.1.0"
}
}
}
provider "aws" {
region = lookup(var.aws_region)
default_tags {
tags = var.resource_tags
}
}
- Initialise the backend, and plan
$ terraform init
$ terraform plan
vpc_name
(string) - Name of the VPC; defaults to empty string.enable_ipv6
(bool) - IPv6 for the VPC; defaults totrue
public_subnet_auto_assign_public_ipv4
- defaults tofalse
public_subnet_enable_ipv6
- defaults tofalse
public_subnet_enable_ipv6_only
- Make public subnet IPv6-native; defaults tofalse
public_subnet_auto_assign_ipv6
- Auto-assign IPv6 to ENI; defaults totrue
public_subnet_enable_dns64
- defaults totrue
⚠️ - prepend all the above withprivate_subnet...
for Private subnet settings
IPv6 settings are logical AND'ed so that ipv6 settings are sane. For example when you set enable_ipv6
to false other ipv6 settings do not take effect.
vpc_id
- VPC IDpublic_subnets
- A list of public subnet IDsprivate_subnets
- A list of private subnet IDsipv6-only_subnets
- A list of private subnet IDsipv4_prefix_list_id
- ID of the prefix list for IPv4 addressesipv6_prefix_list_id
- ID of the prefix list for IPv6 addressesdefault_security_group_id
- ID of the default VPC security group
aws_rfc1918
- A list of AWS restricted CIDRs that can be used for VPC address spacing. Defaults are set.default_tags
- A map of tag keys and values with basic keys and empty values by default
[ref1]: AWS Documentation VPC CIDR blocks - https://docs.aws.amazon.com/vpc/latest/userguide/vpc-cidr-blocks.html
The project is licensed under GNU LGPL. Please make any modifications to this module public. Read LICENSE, COPYING.LESSER, and COPYING files for license text
Copyright (C) 2023 eternaltyro This file is part of Terraform AWS VPC Module aka terraform-aws-vpc project
terraform-aws-vpc is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License.
terraform-aws-vpc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
License text can be found in the repository