def parse_sns_message()

in traffic_mirroring/backfill_handler.py [0:0]


def parse_sns_message(event):
    if "Records" not in event:
        log.error("The event type is either invalid or not supported")
        return []

    next_token = event["Records"][0]["Sns"]["MessageAttributes"]["NextToken"]["Value"]
    response = describe_instances(next_token)

    if not response:
        log.info("Finished backfilling existing instances.")
        return []

    instance_list = []
    for instance in response["Reservations"]:
        instance_details = instance["Instances"][0]
        instance = create_instance_object(instance_details)
        instance_list.append(instance)

    update_sns_config(event, response)

    return instance_list