Search code examples
amazon-web-servicesaws-lambdahttpshttp-postamazon-sns

how to do amazon SNS subscription confirmation and where it will sent the post request of subscription confirmation


I created an Amazon SNS Topic and added https subscription. my problems are how to confirm the subscription.

The problem now is I cannot understand how to confirm the subscription for the HTTPS URL. I cannot see the post request where it is sending request. I am invoking this SNS topic by lambda function using javascript. can someone please help me to do it. Thank you...


Solution

  • From AWS documentation

    After you subscribe your endpoint, Amazon SNS sends a subscription confirmation message to the endpoint. The code at the endpoint must retrieve the SubscribeURL from the subscription confirmation message and then either visit the location specified by the SubscribeURL or make it available to you so that you can manually visit the SubscribeURL, for example, using a web browser.

    Amazon SNS doesn't send messages to an endpoint until the subscription is confirmed. When you visit the SubscribeURL, the response contains an XML document which, in turn, contains the element SubscriptionArn that specifies the ARN for the subscription.

    You can also use the Amazon SNS console to verify that the subscription is confirmed: The Subscription ID displays the ARN for the subscription instead of the PendingConfirmation value from the time when you first added the subscription.

    To confirm the SNS subscription, you can perform the following steps:

    • Log the complete SNS event in CloudWatch, which will allow you to access the SubscribeURL

    C#

    _logger.LogInformation(JsonConvert.SerializeObject(event));
    

    nodejs

    console.info(JSON.stringify(event, null, 2))
    
    • Identify the endpoint of the SubscribeURL within the logged event
    • Manually access the SubscribeURL link in your web browser to confirm the subscription