Skip to content

Commit

Permalink
Add SNS topic and configure event configuration for it
Browse files Browse the repository at this point in the history
  • Loading branch information
philerooski committed Feb 15, 2024
1 parent b19d308 commit d722bcb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ template:
artifact_prefix: '{{ stack_group_config.namespace }}/src/lambda'
dependencies:
- develop/namespaced/s3-event-config-lambda-role.yaml
- develop/namespaced/s3-to-glue-lambda.yaml
- develop/namespaced/sqs-input-to-intermediate.yaml
- develop/s3-input-bucket.yaml
- develop/namespaced/sns-topic.yaml
stack_name: '{{ stack_group_config.namespace }}-lambda-S3EventConfig'
stack_tags: {{ stack_group_config.default_stack_tags }}
parameters:
Namespace: {{ stack_group_config.namespace }}
S3ToGlueDestinationArn: !stack_output_external "{{ stack_group_config.namespace }}-sqs-input-to-intermediate::PrimaryQueueArn"
S3ToGlueDestinationType: "Queue"
S3ToGlueDestinationArn: !stack_output_external "{{ stack_group_config.namespace }}-sns-input-to-sqs::SnsTopicArn"
S3ToGlueDestinationType: "Topic"
S3EventConfigRoleArn: !stack_output_external "{{ stack_group_config.namespace }}-s3-event-config-lambda-role::RoleArn"
S3SourceBucketName: {{ stack_group_config.input_bucket_name }}
7 changes: 7 additions & 0 deletions config/develop/namespaced/sns-topic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
template:
path: sns-topic.yaml
stack_name: "{{ stack_group_config.namespace }}-sns-input-to-sqs"
parameters:
S3SourceBucketArn: !stack_output_external recover-dev-input-bucket::BucketArn
stack_tags:
{{ stack_group_config.default_stack_tags }}
1 change: 1 addition & 0 deletions src/lambda_function/s3_event_config/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Parameters:
Type: String
Description: The S3 Event Config Destination Type
AllowedValues:
- "Topic"
- "Queue"
- "LambdaFunction"

Expand Down
45 changes: 45 additions & 0 deletions templates/sns-topic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
AWSTemplateFormatVersion: "2010-09-09"

Description: >
Creates a Standard SNS queue which can be used with S3 event notifications.
Parameters:

S3SourceBucketArn:
Type: String
Description: Arn of the S3 bucket where source data are stored.

Resources:

SnsTopic:
Type: "AWS::SNS::Topic"
Properties:
TopicName: !Sub "${AWS::StackName}-Topic"
FifoTopic: false

SnsTopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: Input S3 bucket event notification to SNS
Effect: Allow
Principal:
Service: s3.amazonaws.com
AWS: !Sub '${AWS::AccountId}'
Action:
- sns:Publish
Resource: !Ref SnsTopic
#Condition:
#ArnLike:
# "aws:SourceArn": !Ref S3SourceBucketArn
Topics:
- !Ref SnsTopic

Outputs:

SnsTopicArn:
Value: !Ref SnsTopic
Export:
Name: !Sub "${AWS::Region}-${AWS::StackName}-SnsTopicArn"

0 comments on commit d722bcb

Please sign in to comment.