For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-vpc-without-attached-subnet.md.
A documentation index is available at /llms.txt.
VPCs without any attached subnets can indicate unused or orphaned networks that increase the attack surface and hinder enforcement of network segmentation and security controls.
In CloudFormation, every AWS::EC2::VPC resource should be referenced by at least one AWS::EC2::Subnet via the subnet’s Properties.VpcId (for example, a Ref to the VPC logical ID). This rule flags AWS::EC2::VPC resources defined in the same template that have no AWS::EC2::Subnet resources referencing them. If subnets are created in another stack or outside the template, include the subnet resources in the same template or ensure the VPC/subnet relationship is expressed in CloudFormation to avoid false positives.