Reputation: 22904
I'm trying to setup Amazon Ses notifications to go to my SQS Queue. I'm following instructions how to create SQS queue, then SNS topic, and subscribe one to the other.
However in the management console the subscriptions come up "Pending Confirmation".
I'm using the .NET AWS SDK, how can Confirm the subscription? Or even better, why do I have to confirm? The documentation says
If the owner of the queue creates the subscription, the subscription is automatically confirmed and the subscription should be active almost immediately.
I'm using my AWS credentials for all the API calls as owner so I dont see why I need to confirm but how can I anyways?
private static string CreateBounceTopicAndQueue(IAmazonSQS sqsClient, IAmazonSimpleNotificationService snsClient)
{
// 1. Create an Amazon SQS queue named ses-bounces-queue.
CreateQueueResponse createQueueResponse = sqsClient.CreateQueue(new CreateQueueRequest()
{
QueueName = AppGlobal.SesBouncesQueue,
Attributes = new Dictionary<string, string>() {
{ "ReceiveMessageWaitTimeSeconds", "20" }
}
});
string queueUrl = createQueueResponse.QueueUrl;
// 2. Create an Amazon SNS topic named ses-bounces-topic
CreateTopicResponse createTopicResponse = snsClient.CreateTopic(new CreateTopicRequest
{
Name = AppGlobal.SesBouncesTopic
});
string topicArn = createTopicResponse.TopicArn;
// 3. Configure the Amazon SNS topic to publish to the SQS queue
var response = snsClient.Subscribe(new SubscribeRequest
{
TopicArn = topicArn,
Endpoint = queueUrl,
Protocol = "https"
});
return queueUrl;
}
Upvotes: 3
Views: 1766
Reputation: 178956
You don't subscribe an SQS queue to an SNS topic by creating an https subscription with the queue URL.
You create an "sqs" (not https) protocol subscription with the queue's ARN (not web endpoint) as the endpoint.
protocol
Type: System.String
The protocol you want to use.
...
sqs -- delivery of JSON-encoded message to an Amazon SQS queue
endpoint
Type: System.String
The endpoint that you want to receive notifications. Endpoints vary by protocol...
For the sqs protocol, the endpoint is the ARN of an Amazon SQS queue
Upvotes: 1