async checkRouteTable()

in source/networkFirewallAutomation/lib/ec2-manager.ts [93:115]


  async checkRouteTable(routeTableId: string) {
    // get route table details to check route already exist
    const routeTables = await this.service.describeRouteTables(routeTableId)
    Logger.log(LOG_LEVEL.INFO, routeTables)

    // the describe route table API should always return single value if using
    // route table id
    if (routeTables && routeTables.length > 1) {
      Logger.log(LOG_LEVEL.DEBUG, routeTables)
      throw Error(`Expected only one item in the route table array. Received : ${routeTables.length} `)
    }

    let foundExistingRoute: boolean = false
    // at least 1 value should be present before attempting the iteration
    if (routeTables && routeTables.length == 1) {

      // the for loop would iterate only once
      for (let routeTable of routeTables) {
        foundExistingRoute = await this.checkExistingRoutes(routeTable)
      }
    }
    return foundExistingRoute
  }