EC2 instances must be launched into VPC subnets so they are subject to VPC network controls (routing and security groups) and are not placed in undefined network contexts that can increase exposure risk.
In AWS CloudFormation:
AWS::EC2::Instance resources must define Properties.NetworkInterfaces.
Each NetworkInterfaces[].SubnetId that references an AWS::EC2::Subnet resource must point to a subnet that defines Properties.VpcId.
This rule flags AWS::EC2::Instance resources missing NetworkInterfaces and flags subnet resources referenced by SubnetId when the referenced AWS::EC2::Subnet lacks a VpcId property. If you supply SubnetId as a literal ID or parameter instead of a template resource reference, ensure that the referenced subnet ID belongs to a VPC. The check validates VPC association only when SubnetId points to a template resource.
Secure example with a subnet declaring VpcId and an instance using a network interface that references it: