Skip to content Skip to sidebar Skip to footer

How To Send Sns Topic A Message From Node.js Lambda Function

An SNS topic has been created to call a subscribed Lambda function which adds a user to a group in Cognito. Sending a message to the topic using the console in the web browser work

Solution 1:

The Lambda execution environment might not be waiting for the promise to be returned. Try rewriting your promise code using async/await.

Solution 2:

To allow the function to send messages to the SNS topic, add a policy to the function's execution role giving the appropriate permission like so:

"Action":["sns:Publish",],"Effect":"Allow","Resource":[{"Ref":"arn:aws:sns:ca-central-1:example:example"}]

If the lambda function is defined in a CloudFormation template, this is where you would add this.

If the lambda function is created in the AWS console, go to the permissions tab and navigate to the execution role using the link, and add the above permission to it:

enter image description here

Post a Comment for "How To Send Sns Topic A Message From Node.js Lambda Function"