import six


def ensure_no_access_control(template, resource):
    """Make sure the AccessControl resource, if it exists, does not depend on a resource.

    Args:

        template - the template to check

        resource - the name of the resource

    Returns:

        True if the resource was removed, False if it wasn't there.
    """
    changed = False
    resources = template.get('Resources', {})

    access_control = resources.get('AccessControl', {})

    dependencies = access_control.get('DependsOn', [])
    if isinstance(dependencies, list) and resource in dependencies:
        dependencies.remove(resource)
        changed = True
    elif isinstance(dependencies, six.string_types) and resource == dependencies:
        access_control['DependsOn'] = []
        changed = True

    return changed