diff --git a/packages/aws-cdk/lib/context-providers/vpcs.ts b/packages/aws-cdk/lib/context-providers/vpcs.ts index 0ad6a277ad574..2d2495b1b51c1 100644 --- a/packages/aws-cdk/lib/context-providers/vpcs.ts +++ b/packages/aws-cdk/lib/context-providers/vpcs.ts @@ -234,6 +234,17 @@ 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),