INNER CODE UNIT · Python
get_sqs_queue
miztiik/AWS-Demos · how-to-examples/iam-s3-sqs-sns-video-transcoder.py:317
def get_sqs_queue(self):
"""
Get or create the SQS queue. If it is created, then it is
also subscribed to the SNS topic, and a policy is set to allow
the SNS topic to send messages to the queue.
"""
# Creating a queue is idempotent, so if it already exists
# then we will just get the queue returned.
queue = self.sqs.create_queue(QueueName=self.queue_name)
self.queue_arn = queue.attributes['QueueArn']
# Ensure that we are subscribed to the SNS topic
subscribed = False
topic = self.sns.Topic(self.topic_arn)
for subscription in topic.subscriptions.all():
if subscription.attributes['Endpoint'] == self.queue_arn:
subscribed = True
break