def get_sg_id(connector, instance):
    """
    Get one security groups applied to the given instance.

    :param connector: Active EC2Connection
    :param instance: EC2Object Instance

    :return: EC2Object SecurityGroup
    """
    for sg in connector.get_all_security_groups():
        for inst in sg.instances():
            if inst.id == instance.id:
                return sg