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β
| Name | Type | Description |
|---|---|---|
| region | string | AWS region where the IGW will be deployed |
| vpc_id | string | The ID of the VPC to attach the IGW to |
| environment | string | Tag to specify the deployment environment (e.g., dev, staging, prod) |
π€ Outputsβ
| Name | Description |
|---|---|
| igw_id | The ID of the Internet Gateway |
π Deployment Readinessβ
- β Compatible with Terraform 1.0+
- β Tested with AWS provider 5.x
- π§ͺ Requires IAM permissions for
ec2:CreateInternetGatewayandec2: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.