Ce produit n'est pas pris en charge par le site Datadog que vous avez sélectionné. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
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.
# Plan-JSON-only regression fixture (see test/negative3.json): a
# fresh-create SQS endpoint whose vpc_id references a newly created VPC
# with DNS support enabled (true). Documents the same shape as
# test/positive1.tf, but with enable_dns_support = true, to ensure the
# fresh-create fallback in query.rego does not fire when DNS support is
# actually enabled.
resource"aws_vpc""main"{cidr_block="172.16.0.0/16"enable_dns_support=trueenable_dns_hostnames=true}resource"aws_vpc_endpoint""sqs-vpc-endpoint"{vpc_id=aws_vpc.main.idservice_name="com.amazonaws.us-east-1.sqs"vpc_endpoint_type="Interface"}
Non-Compliant Code Examples
# aws_vpc_endpoint.sqs-vpc-endpoint.vpc_id references aws_vpc.main.id, a
# newly created resource. On a real pre-apply plan the VPC's id is
# unknown, so vpc_id is omitted from planned_values (see
# test/negative3.json for the plan-JSON equivalent). The VPC's own
# enable_dns_support is still fully known, though (it's a direct user
# input, not provider-computed) - detected via the fresh-create fallback
# in query.rego, which derives the VPC's Terraform name from
# _dd_tfplan_meta's unresolved vpc_id reference instead of needing the
# resolved id itself.
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}
# Plan-JSON-only regression fixture (see test/positive4.json): both the VPC
# and the SQS endpoint live inside a child module. The endpoint's vpc_id
# reference ("aws_vpc.sqs_scope_test", module-relative) must be qualified
# with the child module's own scope before it can match the VPC's
# flattened resource key ("module.child.sqs_scope_test") - see
# query.rego's common_lib.reference_targets_resource-based fresh-create
# body. Resource names are deliberately distinct from every other fixture
# in this directory (not "main") to avoid a cross-fixture name collision:
# all positive*.tf/.json files are batched into the same test run, and
# vpcs_by_name/used_refs walk every loaded document, so reusing "main"
# here would let positive1.tf's own aws_vpc.main (also
# enable_dns_support = false) satisfy this fixture's lookup even without
# the module-scope fix, masking a real regression.
module"child"{source="./child"}
1
2
rulesets:- Terraform / AWS # Rules to enforce / AWS.
Demander une démonstration personnalisée
Commencer avec Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.