Skip to main content

Internet Gateway (IGW)

πŸ“¦ Overview​

This Terraform module provisions an AWS Internet Gateway (IGW) and attaches it to a specified VPC, allowing public subnets within that VPC to communicate with the internet.

It’s a foundational component for enabling outbound internet access in public subnet configurations.


βœ… Key Features​

  • Provisions an Internet Gateway resource in AWS
  • Attaches the IGW to a specified VPC
  • Tags the gateway with environment metadata
  • Enables internet connectivity when combined with proper route tables

πŸ’Ό Use Cases​

  • Supporting NAT Gateways and public-facing services like ALBs
  • Enabling EC2 instances in public subnets to reach the internet
  • Forming part of a full VPC network stack for multi-tier applications
  • Laying groundwork for hybrid cloud or secure ingress strategies

πŸ“₯ Input Variables​

NameTypeDescription
regionstringAWS region where the IGW will be deployed
vpc_idstringThe ID of the VPC to attach the IGW to
environmentstringTag to specify the deployment environment (e.g., dev, staging, prod)

πŸ“€ Outputs​

NameDescription
igw_idThe ID of the Internet Gateway

πŸš€ Deployment Readiness​

  • βœ… Compatible with Terraform 1.0+
  • βœ… Tested with AWS provider 5.x
  • πŸ§ͺ Requires IAM permissions for ec2:CreateInternetGateway and ec2:AttachInternetGateway

πŸ› οΈ Example Usage​

module "igw" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//network/igw?ref=v1.0.0"

region = "us-east-1"
vpc_id = "vpc-0123456789abcdef0"
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

🧹 Cleanup Options​

Terraform Destroy (for test environments):

terraform destroy

or

tofu destroy

Manual Deletion (for production environments):

Detach the IGW before deletion:

aws ec2 detach-internet-gateway --internet-gateway-id <igw_id> --vpc-id <vpc_id>
aws ec2 delete-internet-gateway --internet-gateway-id <igw_id>

πŸ›‘οΈ Notes​

This is a Level 1 networking module designed to support public subnet connectivity. For full internet access, pair it with a route table that points 0.0.0.0/0 to this IGW.

πŸ”’ Deployment Package Notice​

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.