def map_ec2route_to_route()

in fbpcp/mapper/aws.py [0:0]


def map_ec2route_to_route(route: Dict[str, Any]) -> Route:
    destination_cidr = route["DestinationCidrBlock"]
    route_target_type = RouteTargetType.OTHER
    route_target_id = ""
    if "VpcPeeringConnectionId" in route:
        route_target_type = RouteTargetType.VPC_PEERING
        route_target_id = route["VpcPeeringConnectionId"]
    elif "GatewayId" in route and route["GatewayId"].startswith("igw-"):
        route_target_type = RouteTargetType.INTERNET
        route_target_id = route["GatewayId"]
    state = RouteState.UNKNOWN
    if route["State"] == "active":
        state = RouteState.ACTIVE
    route_target = RouteTarget(route_target_id, route_target_type)
    return Route(destination_cidr, route_target, state)