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).
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):
…or a modified example which specifies additional options for a queue:
And, as in the other proposal, I expect that the
AWS::SQS::QueuePolicylooks something like this:I think that the
QueueUrlproperty 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).