Error when trying to deploy S3 bucket with SNS event

I’m having trouble figuring out how to set up an S3 event to trigger an SNS topic. When I deploy, I get the following output:

  Serverless Error ---------------------------------------

  An error occurred: TestBucket - Unable to validate the following destination configurations.

Below is my serverless.yml file:

service:
  name: TestStack

# Add the serverless-webpack plugin
plugins:
  - serverless-webpack

provider:
  name: aws
  runtime: nodejs6.10
  variableSyntax: '\$\(([\s\S]+?)\)'

custom:
  stage: $(opt:stage, self:provider.stage)
  topicName: kerpow
  topic: $(self:service)-$(self:custom.topicName)-$(self:custom.stage)
  topicArn:
    Fn::Sub: arn:aws:sns:$(self:provider.region):${AWS::AccountId}:$(self:custom.topic)

functions:
  first:
    handler: first.hello
    events:
      - sns: $(self:custom.topic)

resources:
  Resources:
    TestBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: test-bucket-ab8e0782
        NotificationConfiguration:
          TopicConfigurations:
            - Event: s3:ObjectCreated:Put
              Filter:
                S3Key:
                  Rules:
                    - Name: prefix
                      Value: staging/
              Topic: $(self:custom.topicArn)
1 Like

This could be a bug in Serverless. It’s not creating an AWS::SNS::TopicPolicy according to this document:

https://aws.amazon.com/premiumsupport/knowledge-center/unable-validate-destination-s3/