def get_affected_reachability_analyzer_paths(ec2_session, affected_instances):
    """
    Discovers reachability analyzer paths which are sourced from an IGW
    and destined to one of the affected_instances.
    Args:
        ec2_session (botocore.session.Session): Boto3 session object for EC2
        affected_instances (array of strings): List of affected EC2 instances

    Returns:
        An array of objects:
        {
            instance_id: string,
            network_insights_path_id: string
        }
    """
    impacted_network_insights_paths = []
    network_insights_paths = ec2_session.describe_network_insights_paths()

    if (
        network_insights_paths.get('NetworkInsightsPaths') is None or
        len(network_insights_paths.get('NetworkInsightsPaths')) == 0
    ):
        return impacted_network_insights_paths
    for instance_id in affected_instances:
        for network_insight_path in network_insights_paths.get(
                'NetworkInsightsPaths'):
            if (
                network_insight_path.get('Destination') == instance_id and
                network_insight_path.get('Source').startswith('igw-')
            ):
                # Add path ID to affected_paths
                impacted_network_insights_paths.append({
                    'instance_id': instance_id,
                    'network_insights_path_id': network_insight_path.get('NetworkInsightsPathId'),
                })

    return impacted_network_insights_paths