From 0a4561eb45ac6d125c3e718b5a72a74f3b2d5237 Mon Sep 17 00:00:00 2001 From: mchan9125 Date: Mon, 25 Jul 2022 15:51:33 -0700 Subject: [PATCH] initial commit of s3_event_notification_to_sqs.yaml --- aws/s3/s3_event_notification_to_sqs/README.md | 15 ++++++ .../s3_event_notification_to_sqs.yaml | 50 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 aws/s3/s3_event_notification_to_sqs/README.md create mode 100644 aws/s3/s3_event_notification_to_sqs/s3_event_notification_to_sqs.yaml diff --git a/aws/s3/s3_event_notification_to_sqs/README.md b/aws/s3/s3_event_notification_to_sqs/README.md new file mode 100644 index 00000000..7e1482d5 --- /dev/null +++ b/aws/s3/s3_event_notification_to_sqs/README.md @@ -0,0 +1,15 @@ +# Validate Template + +`aws cloudformation validate-template --template-body file://s3_event_notification_to_sqs.yaml` + +# Create Stack + +`aws cloudformation create-stack --stack-name s3-event-notification-to-sqs --template-body file://s3_event_notification_to_sqs.yaml` + +# Update Stack + +`aws cloudformation updatestack --stack-name s3-event-notification-to-sqs --template-body file://s3_event_notification_to_sqs.yaml` + +# Delete Stack + +`aws cloudformation create-stack --stack-name s3-event-notification-to-sqs` \ No newline at end of file diff --git a/aws/s3/s3_event_notification_to_sqs/s3_event_notification_to_sqs.yaml b/aws/s3/s3_event_notification_to_sqs/s3_event_notification_to_sqs.yaml new file mode 100644 index 00000000..bfc813dc --- /dev/null +++ b/aws/s3/s3_event_notification_to_sqs/s3_event_notification_to_sqs.yaml @@ -0,0 +1,50 @@ +--- +AWSTemplateFormatVersion: '2010-09-09' + +Resources: + + S3Bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: sqs-notification-bucket + NotificationConfiguration: + QueueConfigurations: + - Event: s3:ObjectCreated:* + Queue: !GetAtt IngestQueue.Arn + + IngestQueue: + Type: AWS::SQS::Queue + Properties: + RedrivePolicy: + deadLetterTargetArn: !GetAtt BulkIngestDeadLetterQueue.Arn + maxReceiveCount: 5 + QueueName: !Sub bulk-ingest + + BulkIngestDeadLetterQueue: + Type: AWS::SQS::Queue + Properties: + QueueName: bulk-ingest-dlq + + BulkIngestQueuePolicy: + Type: AWS::SQS::QueuePolicy + Properties: + PolicyDocument: + Version: 2012-10-17 + Statement: + - Effect: Allow + Principal: + Service: s3.amazonaws.com + Action: + - SQS:SendMessage + Resource: !GetAtt IngestQueue.Arn + Condition: + ArnLike: + # note that the bucket ARN defined below may need to be created using + # a format such as arn:aws:s3:::bucket_name + # in order to avoid a circular dependency + # this is untested + aws:SourceArn: arn:aws:s3:*:*:sqs-notification-bucket + StringEquals: + aws:SourceAccount: !Ref AWS::AccountId + Queues: + - !Ref IngestQueue \ No newline at end of file