Example #1
0
def get_topic_arn(topicname = SNS_TOPIC_NAME):
    """
    Returns the topic arn, using our default SNS_TOPIC_NAME or a given parameter
    """
    con = SNSConnection(aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                        aws_access_key_id=AWS_ACCESS_KEY,
                        region=RegionInfo(name=REGION,
                                          endpoint='sns.%s.amazonaws.com' % REGION))
    for t in con.get_all_topics()['ListTopicsResponse']['ListTopicsResult']['Topics']:
        topicarn = t['TopicArn']
        if SNS_TOPIC_NAME in topicarn:
            con.close()
            return topicarn


    con.close()
    return None