Skip to content

Commit

Permalink
implement hasRouteToCloudWAN function
Browse files Browse the repository at this point in the history
  • Loading branch information
VardyNg committed Dec 11, 2024
1 parent c23be8c commit 8ddf38b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/aws-cdk/lib/context-providers/vpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

}

/**
Expand Down

0 comments on commit 8ddf38b

Please sign in to comment.