Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add SQS Redrive option to SNS event #3444

Closed
conao3 opened this issue Nov 24, 2023 · 3 comments
Closed

Feature Request: Add SQS Redrive option to SNS event #3444

conao3 opened this issue Nov 24, 2023 · 3 comments
Assignees

Comments

@conao3
Copy link

conao3 commented Nov 24, 2023

#854 makes it easy to build SNS->SQS->Lambda configurations.

When I looked at the documentation, it was not clear whether the RedrivePolicy was for SNS or SQS.
From the actual behavior, I can guess that this seems to be a RedrivePolicy for SNS.

The failure of the SNS->SQS integration does not need to be taken into account by the average user, and in fact, a Redrive due to an error in the SQS->Lambda integration is required.

Perhaps adding a new key like SqsRedrivePolicy or instructing SAM to automatically create the required SQS when specifying an object in SqsSubscription, like the traditional true, would fulfill the requirement.

Option1: Adding SqsRedrivePolicy

Type: SNS
Properties:
  Topic: arn:aws:sns:us-east-1:123456789012:my_topic
  SqsSubscription: true
  RedrivePolicy:
    deadLetterTargetArn: !GetAtt QueueSNSDlq.Arn
  SqsRedrivePolicy:  # <----- New key for SQS redrive policy
    deadLetterTargetArn: !GetAtt QueueFunctionDlq.Arn
    maxReceiveCount: 1

Using this option requires validation of the reciprocal relationship that SqsSubscription must be specified when using SqsRedrivePolicy.

Option2: Support RedrivePolicy on SqsSubscriptionObject

Type: SNS
Properties:
  Topic: arn:aws:sns:us-east-1:123456789012:my_topic
  RedrivePolicy:
    deadLetterTargetArn: !GetAtt QueueSNSDlq.Arn
  SqsSubscription:
    QueueArn: !Ref TopicFunction
    RedrivePolicy:  # <----- New key for SQS redrive policy
      deadLetterTargetArn: !GetAtt QueueFunctionDlq.Arn
      maxReceiveCount: 1

Using this option requires the SQS to be explicitly created by the user.
(This is a potential issue to be resolved by a separate feature request).

@conao3 conao3 added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Nov 24, 2023
@conao3
Copy link
Author

conao3 commented Nov 24, 2023

Related Documents:

@ConnorRobertson
Copy link

Hello @conao3
If you need to have custom properties (i.e. RedrivePolicy, VisibilityTimeout, etc) set on the SNS->SQS->Lambda generated AWS::SQS::Queue please define a custom SQS Queue. Then in the 'SNS' Event on the AWS::Serverless::Function reference the AWS::SQS::Queue in the SqsSubscription: like below. Please respond if you have any questions, or if this does not work for what you are trying to do.

Resources:
  Topic:
    Type: AWS::SNS::Topic

  MyFunctionTopicEventQueue:
    Type: AWS::SQS::Queue
    Properties:
      RedrivePolicy: 
        deadLetterTargetArn: 
          Fn::GetAtt: 
            - "MyDeadLetterQueue"
            - "Arn"
        maxReceiveCount: 5

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://bucket/key
      Handler: app.lambda_handler
      Runtime: python3.9
      Timeout: 60
      Events:
        TopicEvent:
          Type: SNS
          Properties:
            Topic: !Ref Topic
            RedrivePolicy:
                deadLetterTargetArn: !GetAtt QueueSNSDlq.Arn
            SqsSubscription:
              QueueArn: 
                Fn::GetAtt: 
                  - MyFunctionTopicEventQueue
                  - "Arn"
              QueueUrl: !Ref MyFunctionTopicEventQueue

@ConnorRobertson ConnorRobertson self-assigned this Nov 28, 2023
@xazhao xazhao removed the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Nov 28, 2023
@ConnorRobertson
Copy link

Closing issue. Feel free to reopen or open a new issue if you would like to follow up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants