diff --git a/packages/aws-cdk/lib/context-providers/vpcs.ts b/packages/aws-cdk/lib/context-providers/vpcs.ts index 0ad6a277ad574..7f68ce57b54c4 100644 --- a/packages/aws-cdk/lib/context-providers/vpcs.ts +++ b/packages/aws-cdk/lib/context-providers/vpcs.ts @@ -234,11 +234,24 @@ class RouteTables { ); } + + /** + * Whether the given subnet has a route to a CloudWAN Network + */ + public hasRouteToCloudWAN(subnetId: string | undefined): boolean { + const table = this.tableForSubnet(subnetId) || this.mainRouteTable; + + return ( + !!table && !!table.Routes && table.Routes.some((route) => !!route.CoreNetworkArn && route.DestinationCidrBlock === '0.0.0.0/0') + ); + } + public tableForSubnet(subnetId: string | undefined) { return this.tables.find( (table) => !!table.Associations && table.Associations.some((assoc) => assoc.SubnetId === subnetId), ); } + } /**