title: How to prompt AWS SNS to send a confirmation message to a Cloudformation-created subscription?
body: <p>Via CloudFormation, I am trying to create a queue and subscribe it to an existing topic</p>
  
  <pre><code>$ cat ops/queue-and-subscription.yaml
  AWSTemplateFormatVersion: 2010-09-09
  Description: &gt;-
    Minimal template
  
  Resources:
    Queue:
      Type: 'AWS::SQS::Queue'
  
    Subscription:
      Type: 'AWS::SNS::Subscription'
      Properties:
        Endpoint:
          Fn::GetAtt:
            - "Queue"
            - "Arn"
        Protocol: "sqs"
        RawMessageDelivery: true
        TopicArn: "&lt;existing Topic ARN&gt;"
  
  Outputs:
    QueueARN:
      Description: "ARN of the queue set up temporarily for testing"
      Value:
        Fn::GetAtt:
          - "Queue"
          - "Arn"
    QueueURL:
      Description: "URL of the queue. This is required for receiving messages"
      Value: !Ref Queue
  $ aws cloudformation create-stack --stack-name my-test-stack --template-body file://ops/queue-and-subscription.yaml
  {
      "StackId": "&lt;stackId&gt;"
  }
  [...wait...]
  $ aws cloudformation describe-stacks --query 'Stacks[?StackName==`my-test-stack`] | [0].StackStatus'
  "CREATE_COMPLETE"
  $ aws cloudformation describe-stacks --query 'Stacks[?StackName==`my-test-stack`] | [0].Outputs[?OutputKey==`QueueURL`] | [0].OutputValue'
  "&lt;queueUrl&gt;"
  $ aws sqs receive-message --queue-url &lt;queueUrl&gt;
  [null]
  </code></pre>
  
  <p>I expected that a confirmation message would be put directly onto the queue (which I would need to read and pass to a <code>confirm-subscription</code> call <a href="https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html" rel="nofollow noreferrer">docs</a>. However, no such message is ever passed to the queue.</p>
  
  <p>How can I prompt AWS (through SDK, not UI) to send the confirmation message so that I can confirm the subscription?</p>
  
  <hr>
  
  <p>EDIT: I should note that I just tried a similar approach, but creating the SNS Topic within the template (and referring to it with <code>!Ref Topic</code>) - same behaviour, no confirmation message.</p>
  
  <hr>
  
  <p>EDIT2: I suspect that this is because I haven't provided an <a href="https://docs.aws.amazon.com/sns/latest/dg/SendMessageToSQS.cloudformation.html" rel="nofollow noreferrer">SQS Queue Policy</a>. Trying that now.</p>