-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ETL-535] Set up SQS to receive S3 event notification (#75)
* add initial sqs queue setup * add changes to event config lambda to support sending to SQS queues * add missing aws service param and change destination arn to sqs queue * add allowed values, add prod ver of sqs queue and event conifg lambda --------- Co-authored-by: Rixing Xu <[email protected]> Co-authored-by: Rixing Xu <[email protected]>
- Loading branch information
1 parent
03abdda
commit f729901
Showing
9 changed files
with
185 additions
and
18 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
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,13 @@ | ||
template: | ||
path: sqs-queue.yaml | ||
parameters: | ||
MessageRetentionPeriod: '86400' | ||
ReceiveMessageWaitTimeSeconds: '20' | ||
VisibilityTimeout: '120' | ||
S3SourceBucketArn: !stack_output_external recover-dev-input-bucket::BucketArn | ||
dependencies: | ||
- develop/namespaced/s3-to-glue-lambda.yaml | ||
- develop/s3-input-bucket.yaml | ||
stack_name: '{{ stack_group_config.namespace }}-sqs-S3ToLambda' | ||
stack_tags: | ||
{{ stack_group_config.default_stack_tags }} |
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
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,13 @@ | ||
template: | ||
path: sqs-queue.yaml | ||
parameters: | ||
MessageRetentionPeriod: '86400' | ||
ReceiveMessageWaitTimeSeconds: '20' | ||
VisibilityTimeout: '120' | ||
S3SourceBucketArn: !stack_output_external recover-input-bucket::BucketArn | ||
dependencies: | ||
- prod/namespaced/s3-to-glue-lambda.yaml | ||
- prod/s3-input-bucket.yaml | ||
stack_name: '{{ stack_group_config.namespace }}-sqs-S3ToLambda' | ||
stack_tags: | ||
{{ stack_group_config.default_stack_tags }} |
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
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
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
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,70 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
|
||
Description: > | ||
Creates an SQS queue that gets S3 notifications | ||
Parameters: | ||
|
||
MessageRetentionPeriod: | ||
Type: Number | ||
Default: 1209600 | ||
Description: How long to retain messages in the primary queue. | ||
|
||
ReceiveMessageWaitTimeSeconds: | ||
Type: Number | ||
Default: 20 | ||
Description: The delay between SQS receiving a message and making it available for others to poll | ||
|
||
VisibilityTimeout: | ||
Type: Number | ||
Default: 120 | ||
Description: >- | ||
How long our lambda has to submit the messages to Glue and | ||
delete the message from the SQS queue | ||
S3SourceBucketArn: | ||
Type: String | ||
Description: Arn of the S3 bucket where source data are stored. | ||
|
||
Resources: | ||
|
||
PrimaryQueue: | ||
Type: AWS::SQS::Queue | ||
Properties: | ||
DelaySeconds: 0 | ||
MessageRetentionPeriod: !Ref MessageRetentionPeriod | ||
QueueName: !Sub '${AWS::StackName}-Queue' | ||
ReceiveMessageWaitTimeSeconds: !Ref ReceiveMessageWaitTimeSeconds | ||
VisibilityTimeout: !Ref VisibilityTimeout | ||
|
||
PrimaryQueuePolicy: | ||
Type: AWS::SQS::QueuePolicy | ||
Properties: | ||
PolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Sid: Send_Permission | ||
Effect: Allow | ||
Principal: | ||
Service: s3.amazonaws.com | ||
AWS: !Sub '${AWS::AccountId}' | ||
Action: | ||
- SQS:SendMessage | ||
Resource: !GetAtt PrimaryQueue.Arn | ||
Condition: | ||
ArnLike: | ||
"aws:SourceArn": !Ref S3SourceBucketArn | ||
Queues: | ||
- !Ref PrimaryQueue | ||
|
||
Outputs: | ||
|
||
PrimaryQueueArn: | ||
Value: !GetAtt PrimaryQueue.Arn | ||
Export: | ||
Name: !Sub '${AWS::Region}-${AWS::StackName}-PrimaryQueueArn' | ||
|
||
PrimaryQueueUrl: | ||
Value: !Ref PrimaryQueue | ||
Export: | ||
Name: !Sub '${AWS::Region}-${AWS::StackName}-PrimaryQueueUrl' |
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