Skip to content

hazelops/terraform-aws-ec2-nat

Repository files navigation

Terraform EC2 NAT Host Module

AWS Doc about VPC NAT Instance

Usage

module "nat_instance" {
    source    = "hazelops/ec2-nat/aws"
    version   = "~> 3.0"
    enabled                 = var.nat_gateway_enabled ? false : true
    env                     = var.env
    vpc_id                  = module.vpc.vpc_id
    allowed_cidr_blocks     = [module.vpc.vpc_cidr_block]
    public_subnets          = module.vpc.public_subnets
    private_route_table_id  = module.vpc.private_route_table_ids[0]
    ec2_key_pair_name       = var.ec2_key_pair_name
}

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
aws 5.77.0
template n/a

Modules

No modules.

Resources

Name Type
aws_eip.this resource
aws_eip_association.nat_instance resource
aws_instance.this resource
aws_route.this resource
aws_security_group.this resource
aws_ami.this data source
aws_availability_zones.all data source
aws_caller_identity.current data source
template_file.ec2_user_data data source

Inputs

Name Description Type Default Required
allowed_cidr_blocks List of network subnets that are allowed list(string)
[
"0.0.0.0/0"
]
no
architecture NAT instance architecture list(string)
[
"arm64"
]
no
ec2_key_pair_name n/a any n/a yes
eip_enabled Gives ability to enable or disable creation of Elastic IP bool false no
enabled Gives ability to enable or disable creation of NAT EC2 bool false no
env n/a any n/a yes
instance_type NAT instance type string "t4g.nano" no
name NAT instance name string "nat-instance" no
private_route_table_id n/a any n/a yes
public_subnets n/a any n/a yes
vpc_id n/a any n/a yes

Outputs

Name Description
instance_id n/a
private_ip n/a
public_ip n/a
security_group n/a