def handle_event()

in traffic_mirroring/app_helper.py [0:0]


def handle_event(ec2, instance, config):
    if instance.tags and "tags" in config:
        for tag_config in config["tags"]:
            matched_tags = find_matching_tags(instance.tags, tag_config["tagList"])
            if matched_tags:
                log.info("Instance's tags matches the tracked tags %s", matched_tags)
                create_session(ec2, instance, tag_config)
                return

    if "subnets" in config:
        for subnet_config in config["subnets"]:
            if instance.subnet_id == subnet_config["subnetId"]:
                log.info("Instance's subnet matches the tracked subnet %s", instance.subnet_id)
                create_session(ec2, instance, subnet_config)
                return

    if "vpcs" in config:
        for vpc_config in config["vpcs"]:
            if instance.vpc_id == vpc_config["vpcId"]:
                log.info("Instance's vpc matches the tracked vpc %s", instance.vpc_id)
                create_session(ec2, instance, vpc_config)
                return
    
    log.info("Instance's properties does not match the tracked tags/subnets/VPCs")