lib/propono/components/queue_subscription.rb in propono-0.5.5 vs lib/propono/components/queue_subscription.rb in propono-0.5.6

- old
+ new

@@ -18,11 +18,11 @@ def create @topic = TopicCreator.find_or_create(@topic_id) @queue = QueueCreator.find_or_create(queue_name) sns.subscribe(@topic.arn, @queue.arn, 'sqs') - sqs.set_queue_attributes(@queue.url, "Policy", policy) + sqs.set_queue_attributes(@queue.url, "Policy", generate_policy) end def queue_name @queue_name ||= "#{config.application_name.gsub(" ", "_")}-#{@topic_id}" end @@ -31,31 +31,26 @@ def config Configuration.instance end - def policy + def generate_policy <<-EOS - { - "Version": "2008-10-17", - "Id": "arn:aws:sqs:eu-west-1:950417255687:manual_queue/SQSDefaultPolicy", - "Statement": [ - { - "Sid": "Sid1382106399628", - "Effect": "Allow", - "Principal": { - "AWS": "*" - }, - "Action": "SQS:SendMessage", - "Resource": "arn:aws:sqs:eu-west-1:950417255687:manual_queue", - "Condition": { - "ArnEquals": { - "aws:SourceArn": "arn:aws:sns:eu-west-1:950417255687:metrics" - } - } - } - ] - } +{ + "Version": "2008-10-17", + "Id": "#{@queue.arn}/SQSDefaultPolicy", + "Statement": [ + { + "Sid": "#{@queue.arn}-Sid", + "Effect": "Allow", + "Principal": { + "AWS": "*" + }, + "Action": "SQS:*", + "Resource": "#{@queue.arn}" + } + ] +} EOS end end end