AWS::SNS::TopicPolicy - Invalid template resource property 'Topics'

Hi there!

i’m trying to create SNS topic and attach Policy to it. Here is a resource definition

resources:
  Resources:

    SnsFeedTopic:
      Type: AWS::SNS::Topic
      Properties:
        DisplayName: "Events Queue"
        TopicName: avro-feed

    SnsFeedTopicPolicy:
      Type: AWS::SNS::TopicPolicy
      Properties:
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Sid: SnsFeedTopicPolicy
              Effect: Allow
              Principal:
                Service: s3.amazonaws.com
              Action: sns:Publish
      Topics:
        - Ref: SnsFeedTopic

and here is an error

Error --------------------------------------------------

The CloudFormation template is invalid: Invalid template resource property 'Topics'

   For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Get Support --------------------------------------------
   Docs:          docs.serverless.com
   Bugs:          github.com/serverless/serverless/issues
   Forums:        forum.serverless.com
   Chat:          gitter.im/serverless/serverless

Your Environment Information -----------------------------
   OS:                     darwin
   Node Version:           8.4.0
   Serverless Version:     1.21.1

same to raw ARN definition

FIXED

really dump error, just used CloudFront designer to debug an error

Here are SNS resources with an attached policy

resources:
  Resources:
    SnsFirstTopic:
      Type: AWS::SNS::Topic
      Properties:
        DisplayName: First SNS Topic
        TopicName: first-avro-stream
    SnsSecondTopic:
      Type: AWS::SNS::Topic
      Properties:
        DisplayName: Second SNS Topic
        TopicName: second-avro-stream
    SnsTopicPolicy:
      Type: AWS::SNS::TopicPolicy
      Properties:
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Sid: SnsTopicPolicy
            Effect: Allow
            Principal:
              Service: s3.amazonaws.com
            Action: sns:Publish
            Resource: "*"
        Topics:
          - Ref: SnsFirstTopic
          - Ref: SnsSecondTopic

hint: take care about proper indentation for Topics

2 Likes

Thank you. You saved me some time.