Ensure the named sns topic is deleted.

    name
        Name of the SNS topic.

    unsubscribe
        If True, unsubscribe all subcriptions to the SNS topic before
        deleting the SNS topic

    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 topic_absent(name, unsubscribe=False, region=None, key=None, keyid=None, profile=None):
    '''
    Ensure the named sns topic is deleted.

    name
        Name of the SNS topic.

    unsubscribe
        If True, unsubscribe all subcriptions to the SNS topic before
        deleting the SNS topic

    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': {}}

    something_changed = False
    current = __salt__['boto3_sns.describe_topic'](name, region, key, keyid, profile)
    if not current:
        ret['comment'] = 'AWS SNS topic {0} absent.'.format(name)
    else:
        TopicArn = current['TopicArn']
        if __opts__['test']:
            ret['comment'] = 'AWS SNS topic {0} would be removed.'.format(TopicArn)
            if unsubscribe:
                ret['comment'] += '  {0} subscription(s) would be removed.'.format(
                        len(current['Subscriptions']))
            ret['result'] = None
            return ret
        if unsubscribe:
            for sub in current['Subscriptions']:
                if sub['SubscriptionArn'] == 'PendingConfirmation':
                    # The API won't let you delete subscriptions in pending status...
                    log.warning(
                        'Ignoring PendingConfirmation subscription %s %s on '
                        'topic %s', sub['Protocol'], sub['Endpoint'], sub['TopicArn']
                    )
                    continue
                if __salt__['boto3_sns.unsubscribe'](sub['SubscriptionArn'], region=region, key=key,
                                                     keyid=keyid, profile=profile):
                    log.debug('Deleted subscription %s for SNS topic %s', sub, TopicArn)
                    something_changed = True
                else:
                    ret['comment'] = 'Failed to delete subscription {0} for SNS topic {1}'.format(
                            sub, TopicArn)
                    ret['result'] = False
                    return ret
        if not __salt__['boto3_sns.delete_topic'](TopicArn, region=region, key=key, keyid=keyid,
                                                  profile=profile):
            ret['comment'] = 'Failed to delete SNS topic {0}'.format(TopicArn)
            log.error(ret['comment'])
            ret['result'] = False
        else:
            ret['comment'] = 'AWS SNS topic {0} deleted.'.format(TopicArn)
            if unsubscribe:
                ret['comment'] += '  '.join(['Subscription {0} deleted'.format(s)
                                              for s in current['Subscriptions']])
            something_changed = True

    if something_changed:
        ret['changes']['old'] = current
        ret['changes']['new'] = __salt__['boto3_sns.describe_topic'](name, region, key, keyid, profile)
    return ret