SNS Topic说它想要一个字符串

时间:2019-05-06 22:02:40

标签: amazon-web-services amazon-cloudformation serverless-framework

我浏览了几本指南,它们都遵循相同的模式,但仍然出现以下错误:

An error occurred: IngestSNSTopic - Value of property Endpoint must be of type String.

此处使用无服务器框架来声明该资源。我已经遍历了几个小时,谢谢您的帮助。

    IngestSNSTopic:
      Type: AWS::SNS::Topic
      Properties:
        Subscription:
          -
            Endpoint:
              Fn::GetAtt:
                - IngestQueue
                - Arn
              Protocol: sqs
    IngestQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: ${opt:stage}-mam-ingest-queue-${file(env/${opt:stage, 'dev'}.yml):IP_SLUG}
        RedrivePolicy:
          maxReceiveCount: 3
          deadLetterTargetArn:
            Fn::GetAtt:
              - IngestDeadLetter
              - Arn

1 个答案:

答案 0 :(得分:1)

我认为AWS docs are actually incorrect,JSON和YAML示例的输出有所不同。 Protocol属性的缩进次数过多,这意味着Endpoint将作为对象求值。

这是您的配置在JSON中求值的结果:

{
    "IngestSNSTopic": {
        "Type": "AWS::SNS::Topic",
        "Properties": {
            "Subscription": [
                {
                    "Endpoint": {
                        "Fn::GetAtt": [
                            "IngestQueue",
                            "Arn"
                        ],
                        "Protocol": "sqs"
                    }
                }
            ]
        }
    }
}

这就是我的想法:

    IngestSNSTopic:
      Type: AWS::SNS::Topic
      Properties:
        Subscription:
          -
            Endpoint:
              Fn::GetAtt:
                - IngestQueue
                - Arn
            Protocol: sqs