Skip to content

Commit

Permalink
feat(route-tables): add function to check route to CloudWAN Network
Browse files Browse the repository at this point in the history
- Implemented  to determine if a subnet has a route to a CloudWAN Network.
- The function checks the associated route table for routes with  and a destination CIDR of .
  • Loading branch information
VardyNg committed Dec 12, 2024
1 parent c23be8c commit e9b1192
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/aws-cdk/lib/context-providers/vpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit e9b1192

Please sign in to comment.