Description
map_public_ip_on_launch = true assigns public IPv4 addresses by default to new instances in the subnet. Instance launch settings can override it.
Potential impact
Each internal instance launched there may receive a public address. Internet gateway routes, security groups, and network ACLs determine whether outside clients can reach it.
Remediation
Set map_public_ip_on_launch = false on internal subnets. Separate private workloads from public entry points, check launch overrides, and provide the outbound connections each workload needs.
Examples
Before
hcl
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "example" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
tags = {
Name = "Positive"
}
map_public_ip_on_launch = true
}
After
hcl
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "example" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
tags = {
Name = "Negative2"
}
map_public_ip_on_launch = false
}
Changing the subnet default leaves existing addresses in place. Review them and their access rules separately.