in source/networkFirewallAutomation/lib/ec2-manager.ts [124:151]
async checkExistingRoutes(routeTable: EC2.RouteTable): Promise<boolean> {
const routes = routeTable.Routes
Logger.log(LOG_LEVEL.DEBUG, `print routes`)
Logger.log(LOG_LEVEL.DEBUG, routes)
if (routes) {
for (let route of routes) {
Logger.log(LOG_LEVEL.DEBUG, `Checking route below for VPC Endpoint: ${this.vpcEndpoint}`)
Logger.log(LOG_LEVEL.DEBUG, route)
if (route.GatewayId && route.GatewayId === this.vpcEndpoint &&
route.DestinationCidrBlock === Route.default && route.State === Route.active) {
Logger.log(LOG_LEVEL.INFO, `Found Firewall VPC Endpoint ${route.GatewayId}`)
Logger.log(LOG_LEVEL.INFO, `setting foundExistingRoute to TRUE`)
return Promise.resolve(true)
} else if (route.GatewayId && route.GatewayId != this.vpcEndpoint && route.DestinationCidrBlock === Route.default && route.State === Route.active) {
//remove the route entry as possibly the firewall end point is no longer the same as it was earlier.
if (routeTable.RouteTableId) {
await this.service.deleteRoute({
DestinationCidrBlock: Route.default,
RouteTableId: routeTable.RouteTableId
})
}
}
}
}
// return false - could not find existing route
Logger.log(LOG_LEVEL.INFO, `Firewall VPC Endpoint not found as destination in the route table.`)
return Promise.resolve(false)
}