Pattern: Use of public IP for AWS EC2 subnet
Issue: -
You should limit the provision of public IP addresses for resources. Resources should not be exposed on the public internet, but should have access limited to consumers required for the function of your application.
Resolution: Set the instance to not be publicly accessible.
The following example will fail the aws-ec2-no-public-ip-subnet check.
resource "aws_subnet" "bad_example" {
vpc_id = "vpc-123456"
map_public_ip_on_launch = true
}
The following example will pass the aws-ec2-no-public-ip-subnet check.
resource "aws_subnet" "good_example" {
vpc_id = "vpc-123456"
map_public_ip_on_launch = false
}