AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Sends notifications from S3 to SNS when an object is created Parameters: SourceBucketName: Type: String Resources: ## S3 bucket SourceBucket: Type: AWS::S3::Bucket DependsOn: - SNSTopicPolicy Properties: BucketName: !Ref SourceBucketName NotificationConfiguration: TopicConfigurations: - Event: s3:ObjectCreated:* Topic: !Ref SNSTopic SNSTopic: Type: AWS::SNS::Topic SNSTopicPolicy: Type: AWS::SNS::TopicPolicy Properties: PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: 's3.amazonaws.com' Action: sns:Publish Resource: !Ref SNSTopic Condition: ArnEquals: aws:SourceArn: !Join ["",['arn:aws:s3:::',!Ref SourceBucketName]] StringEquals: aws:SourceAccount: !Ref 'AWS::AccountId' Topics: - !Ref SNSTopic