Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 Option to EventBridge #1919

Closed
chrisoverzero opened this issue Feb 8, 2021 · 0 comments
Closed

Feature Request: Add SQS Option to EventBridge #1919

chrisoverzero opened this issue Feb 8, 2021 · 0 comments

Comments

@chrisoverzero
Copy link
Contributor

chrisoverzero commented Feb 8, 2021

Describe your idea/feature/enhancement

Similar to how SAM allows SQS buffering for SNS events, I would like SAM to SQS-buffer EventBridge events.

Proposal

Mostly, I'll be modifying examples from the SNS–SQS proposal.

Given default settings for a queue (that is, a queue created by SAM):

Type: EventBridgeRule
Properties:
  EventBusName: ExternalEventBridge
  Pattern:
    detail:
      state:
      - terminated
  # new property that creates an SQS queue between the rule and Lambda function
  # When only the boolean is specified, SAM uses the following defaults:
  # AWS::SQS::Queue logicalId: <function logicalId><EventBridge event key>Queue
  # AWS::SQS::QueuePolicy logicalId: <function logicalId><EventBridge event key>QueuePolicy
  # BatchSize: default behavior - don't add to `AWS::Lambda::EventSourceMapping` resource so default value is used.
  # MaximumBatchingWindowInSeconds - don't add to `AWS::Lambda::EventSourceMapping` resource so default value is used.
  # Enabled: default behavior - don't add to `AWS::Lambda::EventSourceMapping` resource so default value is used.
  SqsSubscription: true

…or a modified example which specifies additional options for a queue:

Type: EventBridgeRule
Properties:
  EventBusName: ExternalEventBridge
  Pattern:
    detail:
      state:
      - terminated
  # new property that creates an SQS queue between the topic and Lambda function
  # Default values can be overridden by passing an object instead of a boolean. Supported keys:
  # QueuePolicyLogicalId: overrides default logicalId naming of the AWS::SQS::QueuePolicy resource.
  # QueueArn: allows the user to specify their own queue instead of having SAM create one on their behalf, allowing them to specify non-default properties on the queue.
  # BatchSize: if specified, add BatchSize property with given value to `AWS::Lambda::EventSourceMapping` resource.
  # MaximumBatchingWindowInSeconds: if specified, add MaximumBatchingWindowInSeconds property with given value to `AWS::Lambda::EventSourceMapping` resource.
  # Enabled: if specified, add Enabled property with given value to `AWS::Lambda::EventSourceMapping` resource.
  SqsSubscription:
    QueuePolicyLogicalId: CustomQueuePolicyLogicalId
    QueueArn: !GetAtt MyCustomQueue.Arn
    BatchSize: 25
    MaximumBatchingWindowInSeconds: 30
    Enabled: false

And, as in the other proposal, I expect that the AWS::SQS::QueuePolicy looks something like this:

ExampleQueuePolicy:
  Type: AWS::SQS::QueuePolicy
  Properties:
    Queues:
    - !Ref ExampleQueue
    PolicyDocument:
      Version: 2012-10-17
      Statement:
        Effect: Allow
        Principal:
          Service: !Sub events.${AWS::URLSuffix}
        Action: sqs:SendMessage
        Resource: !GetAtt ExampleQueue.Arn
        Condition:
          ArnEquals:
            aws:SourceArn: !GetAtt Example.Arn

I think that the QueueUrl property was added after the proposal was created, which will be necessary to create the queue policy. If this is grossly accepted, I will address those details in the implementation, natch.

Additional Details

I am able to take this work on soon, but not immediately. (Of course, if someone is motivated to get to it before I can, that’s great!)

This should rhyme with @53ningen's implementation of the SNS–SQS feature a lot, I think. Within my company, we use this pattern over and over and over, and I think that SAM can provide a good and related abstraction by synthesizing the rule and the queue policy here (as it does similarly for SNS).

@elbayaaa elbayaaa added stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature area/event-source labels Feb 11, 2021
@aws aws locked and limited conversation to collaborators Feb 7, 2024
@jfuss jfuss converted this issue into discussion #3533 Feb 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

4 participants