Created
October 10, 2023 02:43
-
-
Save miclip/5f29affaba8e76fba429aba3f71f9d4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: > | |
sqs-single-queue-fan-out | |
Sample SAM Template for a single SQS queue fan out using Event Bridge | |
Globals: | |
Function: | |
Timeout: 3 | |
MemorySize: 128 | |
Tracing: Active | |
Api: | |
TracingEnabled: true | |
Resources: | |
SourceQueue: | |
Type: AWS::SQS::Queue | |
Properties: | |
QueueName: 'SourceQueue' | |
ReadNotificationsQueue: | |
Type: AWS::SQS::Queue | |
Properties: | |
QueueName: 'ReadNotificationsQueue' | |
DeleteNotificationsQueue: | |
Type: AWS::SQS::Queue | |
Properties: | |
QueueName: 'DeleteNotificationsQueue' | |
ExamplePipe: | |
Type: AWS::Pipes::Pipe | |
Properties: | |
Name: ExamplePipe | |
RoleArn: !GetAtt EventPipeRole.Arn | |
Source: !GetAtt SourceQueue.Arn | |
Target: !GetAtt ExampleCustomEventBus.Arn | |
SourceParameters: | |
SqsQueueParameters: | |
BatchSize: 1 | |
TargetParameters: | |
InputTemplate: > | |
{"body":<$.body>} | |
EventBridgeEventBusParameters: | |
Source: exampleapp.notifications | |
ExampleCustomEventBus: | |
Type: AWS::Events::EventBus | |
Properties: | |
Name: 'ExampleCustomEventBus' | |
EventRuleReadNotification: | |
Type: 'AWS::Events::Rule' | |
Properties: | |
Description: Read Notification Message Fan Out | |
EventBusName: !Ref ExampleCustomEventBus | |
State: ENABLED | |
EventPattern: | |
detail: | |
body.type: | |
- ReadNotification | |
source: | |
- exampleapp.notifications | |
Targets: | |
- Arn: !GetAtt ReadNotificationsQueue.Arn | |
Id: Target0 | |
InputPath: '$.detail' | |
EventRuleDeleteNotification: | |
Type: 'AWS::Events::Rule' | |
Properties: | |
Description: Delete Notification Message Fan Out | |
EventBusName: !Ref ExampleCustomEventBus | |
State: ENABLED | |
EventPattern: | |
detail: | |
body.type: | |
- DeleteNotification | |
source: | |
- exampleapp.notifications | |
Targets: | |
- Arn: !GetAtt DeleteNotificationsQueue.Arn | |
Id: Target0 | |
InputPath: '$.detail' | |
EventPipeRole: | |
Type: AWS::IAM::Role | |
Properties: | |
RoleName: EventPipeRole | |
AssumeRolePolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Action: | |
- sts:AssumeRole | |
Principal: { Service: pipes.amazonaws.com} | |
SourceEventBridgePolicy: | |
Type: AWS::IAM::Policy | |
Properties: | |
Roles: | |
- !Ref EventPipeRole | |
PolicyName: 'SourceEventBridgePolicy' | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Action: | |
- sqs:ReceiveMessage | |
- sqs:DeleteMessage | |
- sqs:GetQueueAttributes | |
Resource: !GetAtt SourceQueue.Arn | |
- Effect: Allow | |
Action: events:PutEvents | |
Resource: !GetAtt ExampleCustomEventBus.Arn | |
ReadNotificationEventBridgePolicy: | |
Type: AWS::SQS::QueuePolicy | |
Properties: | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Principal: { Service: events.amazonaws.com } | |
Condition: | |
ArnEquals: | |
'aws:SourceArn': !GetAtt EventRuleReadNotification.Arn | |
Action: | |
- sqs:SendMessage | |
- sqs:GetQueueUrl | |
- sqs:GetQueueAttributes | |
Resource: !GetAtt ReadNotificationsQueue.Arn | |
Queues: | |
- !Ref ReadNotificationsQueue | |
DeleteNotificationEventBridgePolicy: | |
Type: AWS::SQS::QueuePolicy | |
Properties: | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: Allow | |
Principal: { Service: events.amazonaws.com } | |
Condition: | |
ArnEquals: | |
'aws:SourceArn': !GetAtt EventRuleDeleteNotification.Arn | |
Action: | |
- sqs:SendMessage | |
- sqs:GetQueueUrl | |
- sqs:GetQueueAttributes | |
Resource: !GetAtt DeleteNotificationsQueue.Arn | |
Queues: | |
- !Ref DeleteNotificationsQueue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment