Skip to content

Instantly share code, notes, and snippets.

@tkeeber
Created December 11, 2018 15:32
Show Gist options
  • Save tkeeber/74ae3cb39e2a12090fdbb8fce4140891 to your computer and use it in GitHub Desktop.
Save tkeeber/74ae3cb39e2a12090fdbb8fce4140891 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SNS topic to SQS Queue Filtered
Resources:
StatsTopic:
Type: AWS::SNS::Topic
StatsPersistQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 60 # 1 minute
MessageRetentionPeriod: 300 # 5 mins.
StatsProcessQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 60 # 1 minute
MessageRetentionPeriod: 300 # 5 mins.
StatsPersistQueueSubscription:
Type: AWS::SNS::Subscription
Properties:
TopicArn: !Ref StatsTopic
Endpoint: !GetAtt StatsPersistQueue.Arn
Protocol: sqs
JustSomeStatsProcessQueueSubscription:
Type: AWS::SNS::Subscription
Properties:
TopicArn: !Ref StatsTopic
Endpoint: !GetAtt StatsProcessQueue.Arn
Protocol: sqs
FilterPolicy:
statsType:
- SomeStatsType
RawMessageDelivery: true
FilteredStatsUpdatesPolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Id: StatsQueuePolicy
Statement:
- Sid: 'Allow-SendMessage-To-Queues-From-SNS-Topic'
Effect: Allow
Principal:
AWS: '*'
Action:
- 'sqs:SendMessage'
Resource: '*'
Condition:
ArnEquals:
'aws:SourceArn':
Ref: StatsTopic
Queues:
- !Ref StatsPersistQueue
- !Ref StatsProcessQueue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment