Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring SNS Delivery Retry Policies

I would like to know if is possible to configure SNS Delivery Retry Policies through cloudFormation.

I couldn't find it in any online documentation. If such configuration is possible, I would really appreciate if someone could post a snippet showing how to do it.

Thanks in Advance,

like image 938
user2687610 Avatar asked Aug 15 '13 22:08

user2687610


People also ask

Does AWS SNS guaranteed delivery?

Q: Does Amazon SNS guarantee that messages are delivered to the subscribed endpoint? Yes, as long as the subscribed endpoint is accessible. A message delivery fails when Amazon SNS can't access a subscribed endpoint, due to either a client-side or a server-side error.

How many subscriptions can SNS have?

In terms of limits, SNS will scale to any imaginable use case, with 12.5 million subscriptions supported per topic and a limit of 100.000 topics (standard) and 1.000 FIFO topics per account!


2 Answers

AWS CloudFormation sometimes doesn't cover all (new) API actions available within other AWS Products & Services, though they usually get introduced within a few month later on.

Unfortunately, despite SNS Delivery Retry Policies for HTTP/HTTPS Endpoints being introduced in December 2011 already, this feature is still not supported as of today.

Workaround

You might be able to implement a workaround with CloudFormation still by means of the dedicated CustomResource type, which are special AWS CloudFormation resources that provide a way for a template developer to include resources in an AWS CloudFormation stack that are provided by a source other than Amazon Web Services. - the AWS CloudFormation Custom Resource Walkthrough provides a good overview of what this is all about, how it works and what's required to implement your own.

Your custom resource would need to implement the missing support for delivery retry policies by explicitly calling the SetSubscriptionAttributes or SetTopicAttributes API actions with the apparently also undocumented DeliveryPolicy attribute as per the Sample Requests shown there, e.g.:

{
    "healthyRetryPolicy": 
    {
        "minDelayTarget":  <int>,
        "maxDelayTarget": <int>,
        "numRetries": <int>,
        "numMaxDelayRetries": <int>,
        "backoffFunction": "<linear|arithmetic|geometric|exponential>"
    },
    "throttlePolicy":
    {
        "maxReceivesPerSecond": <int>
    }
}
like image 175
Steffen Opel Avatar answered Oct 12 '22 21:10

Steffen Opel


I was able to do this by firstly deploying an AWS SNS Topic using CDK. I then had to create a Lambda function to set the attributes of the topic.

I have created an example of how to do this in the following repository: https://github.com/Milan9805/cdk-set-topic-attributes

There is a GitHub action in the repository that uses cdk to deploy the topic and lambda. Then it invokes the lambda to set the topic attributes.

like image 28
Milan Makwana Avatar answered Oct 12 '22 22:10

Milan Makwana