Ensure CloudWatch event rule with passed properties is absent.

    name
        The name of the state definition.

    Name
        Name of the event rule.  Defaults to the value of the 'name' param if
        not provided.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.

def absent(name, Name=None, region=None, key=None, keyid=None, profile=None):
    '''
    Ensure CloudWatch event rule with passed properties is absent.

    name
        The name of the state definition.

    Name
        Name of the event rule.  Defaults to the value of the 'name' param if
        not provided.

    region
        Region to connect to.

    key
        Secret key to be used.

    keyid
        Access key to be used.

    profile
        A dict with region, key and keyid, or a pillar key (string) that
        contains a dict with region, key and keyid.
    '''

    ret = {'name': Name,
           'result': True,
           'comment': '',
           'changes': {}
           }

    Name = Name if Name else name

    r = __salt__['boto_cloudwatch_event.exists'](Name,
                       region=region, key=key, keyid=keyid, profile=profile)
    if 'error' in r:
        ret['result'] = False
        ret['comment'] = 'Failed to delete event rule: {0}.'.format(r['error']['message'])
        return ret

    if r and not r['exists']:
        ret['comment'] = 'CloudWatch event rule {0} does not exist.'.format(Name)
        return ret

    if __opts__['test']:
        ret['comment'] = 'CloudWatch event rule {0} is set to be removed.'.format(Name)
        ret['result'] = None
        return ret

    # must remove all targets first
    r = __salt__['boto_cloudwatch_event.list_targets'](Rule=Name,
                                    region=region, key=key,
                                    keyid=keyid, profile=profile)
    if not r.get('targets'):
        ret['result'] = False
        ret['comment'] = 'Failed to delete event rule: {0}.'.format(r['error']['message'])
        return ret
    ids = [t.get('Id') for t in r['targets']]
    if bool(ids):
        r = __salt__['boto_cloudwatch_event.remove_targets'](Rule=Name, Ids=ids,
                                    region=region, key=key,
                                    keyid=keyid, profile=profile)
        if 'error' in r:
            ret['result'] = False
            ret['comment'] = 'Failed to delete event rule: {0}.'.format(r['error']['message'])
            return ret
        if r.get('failures'):
            ret['result'] = False
            ret['comment'] = 'Failed to delete event rule: {0}.'.format(r['failures'])
            return ret

    r = __salt__['boto_cloudwatch_event.delete'](Name,
                                    region=region, key=key,
                                    keyid=keyid, profile=profile)
    if not r['deleted']:
        ret['result'] = False
        ret['comment'] = 'Failed to delete event rule: {0}.'.format(r['error']['message'])
        return ret
    ret['changes']['old'] = {'rule': Name}
    ret['changes']['new'] = {'rule': None}
    ret['comment'] = 'CloudWatch event rule {0} deleted.'.format(Name)
    return ret