Kevin
Kevin

Reputation: 162

SNS Topic says it wants a string

I have looked around through several guides and they all follow this same pattern, yet I still get the following error:

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

Using the serverless framework here is the section that declares that resource. I have been going over and over this for a few hours now, would love some help, thanks.

    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

Upvotes: 2

Views: 774

Answers (1)

noetix
noetix

Reputation: 4933

I think the AWS docs are actually incorrect, the JSON and YAML examples differ in output. The Protocol property is indented once too many, which means Endpoint would evaluate as an object.

Here is what your config evaluates to in JSON:

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

Here is how I think it should be:

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

Upvotes: 2

Related Questions