无服务器创建snspolicy失败,参数无效

时间:2018-11-26 18:35:54

标签: amazon-web-services amazon-sns serverless

这是错误。

An error occurred: SNSTopicPolicy - Invalid parameter:
Policy Error: null (Service: AmazonSNS; 
Status Code: 400; Error Code: InvalidParameter; 
Request ID: 38a567df-2cff-50bf-8f0e-33a91775cc6e).

我找不到查找日志的地方来告诉我缺少什么参数。我很确定我拥有所需的一切。我正在使用此site及其API页面。

SNSTopic:
  Type: AWS::SNS::Topic
  Properties:
    DisplayName: Aura main Topic
    TopicName: ${file(./env.yml):${opt:stage, self:provider.stage}.env.auraSnsTopicName}

SNSTopicPolicy:
  Type: AWS::SNS::TopicPolicy
  Properties:
    PolicyDocument:
      Id: auraAllowSQSsendrobelrobel
      Statement:
        -
          Effect: Allow
          Action:
            - sns: Publish
          Resource: { "Fn::GetAtt":["SQSQueue" ,"Arn"]}
          Principle:
            AWS: "*"
    Topics:
      - { "Ref": "SNSTopic" }


SQSQueue:
  Type: AWS::SQS::Queue
  Properties:
    QueueName: ${file(./env.yml):${opt:stage, self:provider.stage}.env.eeegPagesQueueName}
    RedrivePolicy:
      deadLetterTargetArn: {"Fn::GetAtt" : [ "SQSQueueDLQ", "Arn" ]}
      maxReceiveCount: 2


SQSQueuePolicy:
  Type: AWS::SQS::QueuePolicy
  Properties:
    PolicyDocument:
      Id: allowSNSSourceAndLambdaTrigger
      Statement:
        -
          Effect: Allow
          Action:
            - SQS:ReceiveMessage
            - SQS:SendMessage
            - SQS:ChangeMessageVisibility
            - SQS:ListDeadLetterSourceQueues
            - SQS:GetQueueUrl
            # - lambda:CreateEventSourceMapping
            # - lambda:ListEventSourceMappings
            # - lambda:ListFunction
          Resource: {"Ref": "SNSTopic"}
    Queues:
      - { "Ref": "SQSQueue" }

我有一个运行良好的SQS政策声明。

  Your Environment Information ----------------------------
     OS:                    Mac darwin
     Node Version:           8.12.0
     Serverless Version:     1.32.0

1 个答案:

答案 0 :(得分:0)

结果证明,您需要进行拼写很重要,并且不需要AWS子对象。 Principal: "*"

以下工作政策:

SNSTopicPolicy:
  Type: AWS::SNS::TopicPolicy
  Properties:
    PolicyDocument:
      Statement:
        - Sid: auraAllowSQSPublish
          Effect: Allow
          Principal: "*"
          Action: "sns:Publish"
          Resource:  { "Ref": "SNSTopic" }
    Topics:
      - { "Ref": "SNSTopic" }