I have Lambda function when invoked it creates SNS topic, adds subscribers to it and then publishes a message to it. After publishing the messages it deletes the topic. The name of the topic to be created and the subscribers are supplied to the lambda function as payload.
Sometimes it works and sometimes it fails with Task timed out after x seconds
I have increased the lambda timeout and still same issue.
I dug a little and found out that
sns.createTopic(params, function(err, data) {
if(err) {
console.log('Error Creating SNS Topic:',err);
} else {
console.log('SNS Topic Created Successfully:',data);
}
}
never returns, no error no data and I don't see result of console.log()
When it works, everything is good but when it fails I can't see to find the issue.
EDIT:
So I did a little more digging, I decreased the timeout of SNS topic creation it was 5 minutes by default now it is 5 seconds. When the failing happens I get this"
{ [TimeoutError: Connection timed out after 5000ms]
message: 'Connection timed out after 5000ms',
code: 'NetworkingError',
time: Thu Mar 30 2017 15:35:20 GMT+0000 (UTC),
region: 'us-east-1',
hostname: 'sns.us-east-1.amazonaws.com',
retryable: true }