   "Returns an access policy allowing the given SNS topic to publish to the given SQS queue."
   [sns-client sqs-client queue-name exchange-names]
   (let [conditions (topic-conditions sns-client exchange-names)
+        queue-arn (get-queue-arn sqs-client queue-name)
+        resource (Resource. queue-arn)
         statement (doto (Statement. Statement$Effect/Allow)
                         (.withPrincipals (into-array Principal [Principal/AllUsers]))
                         (.withActions (into-array SQSActions [SQSActions/SendMessage]))
+                        (.withResources (into-array Resource [resource]))
                         (.withConditions (into-array Condition conditions)))
         policy (.withStatements (Policy.) (into-array Statement [statement]))]
     (.toJson policy)))


;; Tests to make sure SNS/SQS is working
(comment
  ;; create a broker
  (def broker (lifecycle/start (create-queue-broker {}) nil))
  ;; list the topics for the cmr-ingest_exchange exchange/topic
  (get-topic (:sns-client broker) "cmr_ingest_exchange")
  ;; list the queues for the cmr_ingest_exchange
  (queue/get-queues-bound-to-exchange broker "cmr_ingest_exchange")
  ;; create a test queue
  (create-queue (:sqs-client broker) "cmr-test.queue")
  ;; create a test exchange
  (create-exchange (:sns-client broker) "cmr_test_exchange")
  ;; list the queues for the cmr_test_exchange
  (queue/get-queues-bound-to-exchange broker "cmr_test_exchange")
  ;; Bind the queue to the new exchange
  (bind-queue-to-exchanges (:sns-client broker) (:sqs-client broker) ["cmr_test_exchange"] "cmr-test.queue")
  ;; subscribe to test queue with a simple handler that prints received messages
  (queue/subscribe broker "cmr-test.queue" (fn [msg] (println "Got Message: " msg)))
  ;; publish a message to the queue to verify our subscribe worked
  (queue/publish-to-queue broker "cmr-test.queue" "{\"body\": \"ABC\"}")
  ;; publish a message to the exchange to verify the message is sent to the queue
  (queue/publish-to-exchange broker "cmr_test_exchange" "{\"body\": \"ABC-exchange\"}"))

       q-arn (get-queue-arn sqs-client q-name)
       q-url (.getQueueUrl (.getQueueUrl sqs-client q-name))
       ;; create an access policy to allow the topic to publish to the queue
       access-policy (sns-to-sqs-access-policy sns-client sqs-client q-name exchange-names)
       q-attrs (HashMap. {"Policy" access-policy})

       ;; create an empty SetQueueAttributesRequest object and then set the attributes on it
       set-queue-attrs-request (doto (SetQueueAttributesRequest.)
                                     (.setAttributes q-attrs)
                                     (.setQueueUrl q-url))]
