Shekar Tippur
Shekar Tippur

Reputation: 165

AWS SNS publish 404 error

I have a lambda function where I am trying to publish a message to SNS topic:

Here is the code:

var params = {
    Message: origmessage,
    Subject: "Retrying posting URL",
    TopicArn: "arn:aws:sns:us-west-2:<acctid>:SampleTopic"
};
sns.publish(params, function(err, data) {
    if (err) {
        console.log("SNS publish error")
        console.log(err, err.stack)
        console.log(data, data)
        console.log("RETRY PARAMS:" + params);
        context.fail(err);
    }
});

SNS publish error is cryptic as I am unable to find the root cause. Appreciate if someone can help me show a way to debug this.

Here is the error:

2017-01-19T00:41:13.947Z d440064d-dddf-11e6-abad-8de6d2739d36 {
  [404: null]
  message: null,
  code: 404,
  time: Thu Jan 19 2017 00:41:13 GMT+0000 (UTC),
  requestId: '0ENTKJ09RT82VE0SFEUJKT75NVVV4KQNSO5AEMVJF66Q9ASUAAJG',
  statusCode: 404,
  retryable: false,
  retryDelay: 26.97333029936999
}
'404: null
at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/query.js:45:29)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:668:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:670:12)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:115:18)'

Upvotes: 3

Views: 2602

Answers (1)

Matt Houser
Matt Houser

Reputation: 36043

As per your comments, when you use AWS.config.update, it affects all services.

By setting the endpoint parameter to the dynamodb endpoint, you are setting that endpoint for all services, including SNS.

This is an offending example where it says to specify the endpoint for dynamodb:

http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.NodeJs.Summary.html

Instead, the endpoint should be taken out of AWS.config.update and somehow specified in each service's constructor.

Upvotes: 2

Related Questions