CloudWiki

Amazon Web Service (AWS)

Internet Gateway

Network
An internet gateway (IGW) allows resources associated with public IP (IPv4 or IPv6 address) within your VPC to access the internet. Likewise, resources on the internet can initiate a connection to resources in your subnet using the public IPv4 address or IPv6 address.
aws_internet_gateway
Internet Gateway
attributes:
  • vpc_id - (Optional) The VPC ID to create in. See the aws_internet_gateway_attachment resource for an alternate way to attach an Internet Gateway to a VPC.
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Associating resources with a
Internet Gateway
Resources do not "belong" to a
Internet Gateway
Rather, one or more Security Groups are associated to a resource.
Create
Internet Gateway
via Terraform:
The following HCL creates an internet gateway with the tag Name my-igw
Syntax:

resource "aws_internet_gateway" "gw" {
 vpc_id = aws_vpc.main.id

 tags = {
   Name = "my-igw"
 }
}

Create
Internet Gateway
via CLI:
Parametres:

create-internet-gateway
[--tag-specifications <value>]
[--dry-run | --no-dry-run]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]

Example:

aws ec2 create-internet-gateway \
   --tag-specifications ResourceType=internet-gateway,Tags=[{Key=Name,Value=my-igw}]

Best Practices for
Internet Gateway

Categorized by Availability, Security & Compliance and Cost

Info
Ensure Internet Gateway is attached to a VPC
Info
Internet Gateway (IGW) changes alarm
Explore all the rules our platform covers
All Resources