def modify_tags(region, instance_id, tags_to_set_str, tags_to_remove_str):
    instance = get_client(region).Instance(instance_id)
    tags_to_remove = set((tags_to_remove_str.split(',') if tags_to_remove_str else []))
    internal_tags = set(['Name', 'launched-by', 'yb-server-type'])
    if (tags_to_remove & internal_tags):
        raise YBOpsRuntimeError('Was asked to remove tags: {}, which contain internal tags: {}'.format(tags_to_remove, internal_tags))
    if tags_to_remove:
        instance.delete_tags(Tags=[{'Key': k} for k in tags_to_remove])
    tags_to_set = json.loads((tags_to_set_str if tags_to_set_str else '{}'))
    customer_tags = []
    for (k, v) in tags_to_set.iteritems():
        customer_tags.append({'Key': k, 'Value': v})
    instance.create_tags(Tags=customer_tags)
def modify_tags(region, instance_id, tags_to_set_str, tags_to_remove_str):
    instance = get_client(region).Instance(instance_id)
    tags_to_remove = set((tags_to_remove_str.split(',') if tags_to_remove_str else []))
    internal_tags = set(['Name', 'launched-by', 'yb-server-type'])
    if (tags_to_remove & internal_tags):
        raise YBOpsRuntimeError('Was asked to remove tags: {}, which contain internal tags: {}'.format(tags_to_remove, internal_tags))
    if tags_to_remove:
        instance.delete_tags(Tags=[{'Key': k} for k in tags_to_remove])
    tags_to_set = json.loads((tags_to_set_str if tags_to_set_str else '{}'))
    customer_tags = []
    for (k, v) in tags_to_set.iteritems():
        customer_tags.append({'Key': k, 'Value': v})
    instance.create_tags(Tags=customer_tags)