Set a CloudFront distribution to be disabled.

    Id
        Id of the distribution to update.

    region
        Region to connect to.

    key
        Secret key to use.

    keyid
        Access key to use.

    profile
        Dict, or pillar key pointing to a dict, containing AWS region/key/keyid.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudfront.disable_distribution Id=E24RBTSABCDEF0

def disable_distribution(region=None, key=None, keyid=None, profile=None, **kwargs):
    '''
    Set a CloudFront distribution to be disabled.

    Id
        Id of the distribution to update.

    region
        Region to connect to.

    key
        Secret key to use.

    keyid
        Access key to use.

    profile
        Dict, or pillar key pointing to a dict, containing AWS region/key/keyid.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudfront.disable_distribution Id=E24RBTSABCDEF0

    '''
    retries = 10
    sleep = 6
    kwargs = {k: v for k, v in kwargs.items() if not k.startswith('_')}
    authargs = {'region': region, 'key': key, 'keyid': keyid, 'profile': profile}
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    Id = kwargs.get('Id')
    current = get_distribution_v2(Id=Id, **authargs)
    if current is None:
        log.error('Failed to get current config of CloudFront distribution `%s`.', Id)
        return None
    if not current['Distribution']['DistributionConfig']['Enabled']:
        return current

    ETag = current['ETag']
    DistributionConfig = current['Distribution']['DistributionConfig']
    DistributionConfig['Enabled'] = False
    kwargs = {'DistributionConfig': DistributionConfig, 'Id': Id, 'IfMatch': ETag}
    kwargs.update(authargs)
    while retries:
        try:
            log.debug('Disabling CloudFront distribution `%s`.', Id)
            ret = conn.update_distribution(**kwargs)
            return ret
        except botocore.exceptions.ParamValidationError as err:
            raise SaltInvocationError(str(err))
        except botocore.exceptions.ClientError as err:
            if retries and err.response.get('Error', {}).get('Code') == 'Throttling':
                retries -= 1
                log.debug('Throttled by AWS API, retrying in %s seconds...', sleep)
                time.sleep(sleep)
                continue
            log.error('Failed to disable CloudFront distribution `%s`:  %s', Comment, err.message)
            return None