This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sns, sqs, dlq for Subscriptions (#554)
- Loading branch information
1 parent
bf36605
commit fcf6197
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
Resources: | ||
SubscriptionsKey: | ||
Type: 'AWS::KMS::Key' | ||
Properties: | ||
Description: Encryption key for rest hook queue that can be used by SNS | ||
EnableKeyRotation: true | ||
KeyPolicy: | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: 'sns.amazonaws.com' | ||
Action: | ||
- 'kms:Decrypt' | ||
- 'kms:GenerateDataKey*' | ||
Resource: '*' | ||
- Sid: Allow administration of the key | ||
Effect: Allow | ||
Principal: | ||
AWS: !Join ['', ['arn:aws:iam::', !Ref AWS::AccountId, ':root']] | ||
Action: | ||
- 'kms:*' | ||
Resource: '*' | ||
|
||
RestHookQueue: | ||
Type: AWS::SQS::Queue | ||
Properties: | ||
KmsMasterKeyId: !Ref SubscriptionsKey | ||
RedrivePolicy: | ||
deadLetterTargetArn: !GetAtt RestHookDLQ.Arn | ||
maxReceiveCount: 3 | ||
|
||
RestHookDLQ: | ||
Type: AWS::SQS::Queue | ||
Properties: | ||
MessageRetentionPeriod: 1209600 # 14 days in seconds | ||
KmsMasterKeyId: 'alias/aws/sqs' | ||
|
||
RestHookQueuePolicy: | ||
Type: AWS::SQS::QueuePolicy | ||
Properties: | ||
Queues: [!Ref RestHookQueue] | ||
PolicyDocument: | ||
Statement: | ||
- Effect: Deny | ||
Action: | ||
- SQS:* | ||
Resource: | ||
- !GetAtt RestHookQueue.Arn | ||
Principal: '*' | ||
Condition: | ||
Bool: | ||
'aws:SecureTransport': false | ||
- Effect: Allow | ||
Action: | ||
- SQS:SendMessage | ||
Resource: | ||
- !GetAtt RestHookQueue.Arn | ||
Principal: | ||
Service: 'sns.amazonaws.com' | ||
Condition: | ||
ArnEquals: | ||
aws:SourceArn: !Ref SubscriptionsTopic | ||
|
||
RestHookDLQPolicy: | ||
Type: AWS::SQS::QueuePolicy | ||
Properties: | ||
Queues: [!Ref RestHookDLQ] | ||
PolicyDocument: | ||
Statement: | ||
- Effect: Deny | ||
Action: | ||
- SQS:* | ||
Resource: | ||
- !GetAtt RestHookDLQ.Arn | ||
Principal: '*' | ||
Condition: | ||
Bool: | ||
'aws:SecureTransport': false | ||
|
||
SubscriptionsTopic: | ||
Type: AWS::SNS::Topic | ||
Properties: | ||
TopicName: 'SubscriptionsTopic' | ||
KmsMasterKeyId: !Ref SubscriptionsKey | ||
|
||
RestHookSubscription: | ||
Type: 'AWS::SNS::Subscription' | ||
Properties: | ||
TopicArn: !Ref SubscriptionsTopic | ||
Endpoint: !GetAtt RestHookQueue.Arn | ||
Protocol: sqs | ||
FilterPolicy: | ||
channelType: | ||
- 'rest-hook' |
This file contains 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