For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-aws-sqs-vpc-endpoint-without-dns-resolution.md.
A documentation index is available at /llms.txt.
When configuring an Amazon SQS VPC Endpoint using Terraform, it is essential to have DNS resolution enabled for the associated VPC by setting enable_dns_support = true. If this is not set, such as in the configuration enable_dns_support = false, private DNS hostnames are not resolved within the VPC, causing communication failures for instances relying on DNS-based access to AWS services via the endpoint. This can result in application connectivity issues and may force the use of less secure public network routes, increasing the attack surface.
locals{region="us-east-1"cidr_block="172.16.0.0/16"public_subnet_cidr_block="172.16.100.0/24"quad_zero_cidr_block="0.0.0.0/0"}provider"aws"{region=local.region}resource"aws_vpc""main"{cidr_block=local.cidr_blockenable_dns_support=falseenable_dns_hostnames=false}resource"aws_subnet""public-subnet"{vpc_id=aws_vpc.main.idcidr_block=local.public_subnet_cidr_blocktags={Name="public-subnet"}}resource"aws_route_table""public-rtb"{vpc_id=aws_vpc.main.idroute{cidr_block=local.cidr_blockvpc_endpoint_id=aws_vpc_endpoint.sqs-vpc-endpoint.id}route{cidr_block="0.0.0.0/0"gateway_id=aws_internet_gateway.igw.id}tags={Name="public-rtb"}}resource"aws_route_table_association""public-rtb-assoc"{subnet_id=aws_subnet.public-subnet.idroute_table_id=aws_route_table.public-rtb.id}resource"aws_security_group""public-internet-sg"{name="public-internet-sg"description="Allow all local traffic with internet access"vpc_id=aws_vpc.main.idegress{from_port=0to_port=0protocol="-1"cidr_blocks=[local.quad_zero_cidr_block]}ingress{from_port=0to_port=0protocol="-1"cidr_blocks=[local.cidr_block]}}data"aws_ami""ubuntu"{most_recent=truefilter{name="name"values=["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]}filter{name="virtualization-type"values=["hvm"]}owners=["099720109477"] # Canonical
}resource"aws_instance""test-ec2-instance"{ami=data.aws_ami.ubuntu.idinstance_type="t2.micro"subnet_id=aws_subnet.public-subnet.idvpc_security_group_ids=[aws_security_group.public-internet-sg.id]}resource"aws_vpc_endpoint""sqs-vpc-endpoint"{vpc_id=aws_vpc.main.idservice_name="com.amazonaws.${local.region}.sqs"vpc_endpoint_type="Interface"private_dns_enabled=truesubnet_ids=[aws_subnet.public-subnet.id]security_group_ids=[aws_security_group.public-internet-sg.id]}resource"aws_sqs_queue""test-queue"{name="test-queue"}resource"aws_internet_gateway""igw"{vpc_id=aws_vpc.main.id}