aws / serverless-application-model

The AWS Serverless Application Model (AWS SAM) transform is a AWS CloudFormation macro that transforms SAM templates into CloudFormation templates.
https://aws.amazon.com/serverless/sam
Apache License 2.0
9.36k stars 2.38k forks source link

SNS Topic Policy error: Invalid parameter: Policy Error: null when creating #1591

Closed mrichman closed 4 years ago

mrichman commented 4 years ago

I get this error creating an SNS topic policy resource: I get the error "Invalid parameter: Policy Error: null (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: 3c0ff853-89aa-5944-b68c-af673e2bcb6c)"

Here is the relevant template section:

  SynthesisTaskTopic:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName: SynthesisTaskTopic
      TopicName: SynthesisTaskTopic

  SynthesisTaskTopicPolicy:
    Type: AWS::SNS::TopicPolicy
    Properties:
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Sid: AllowPollySNSPermissions
            Effect: Allow
            Principal:
              Service: polly.amazonaws.com
            Action:
              - sns:*
            Resource: !Ref SynthesisTaskTopic
      Topics:
        - !Ref SynthesisTaskTopic

This passes both sam validate and cfn-lint.

I need to grant the Polly service access to publish to my SNS topic.

mrichman commented 4 years ago

So it turns out Polly doesn't work with resource-based policies.