user2687610
user2687610

Reputation: 81

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,

Upvotes: 8

Views: 2926

Answers (3)

Yair Abad
Yair Abad

Reputation: 354

There is a way. Creating a Subscription resource by CF and setting retries policy as you wish subscribing an endpoint to an SNS topic endpoint (sqs, lambda, email...).

Hope it helps :)

Upvotes: 0

Milan Makwana
Milan Makwana

Reputation: 11

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.

Upvotes: 1

Steffen Opel
Steffen Opel

Reputation: 64751

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>
    }
}

Upvotes: 7

Related Questions