Publishing to SNS from Action

Hi all,
I want to publish to an SNS queue using a Post Registration action.

From the looks of it the built in SNS integration only works for SMS so I believe I have to build a custom post registration action.

My current action looks like this

exports.onExecutePostUserRegistration = async (event) => {
    // Load the AWS SDK for Node.js
  // Set region
  var AWS = require("aws-sdk");
  AWS.config.update({region: 'us-east-1'});
  var awsSNS = new AWS.SNS({ 
    credentials: new AWS.Credentials("ACCESS_ID", "ACCESS_SECRET") 
  });

  var params = { Message: JSON.stringify("fromAUth0"), TopicArn: "MY_TOPIC_ARN"};
  awsSNS.publish(params);

}

When I run this (with my key/secret/arn filled in) I get a 200 response, but I don’t see any results from my lambda (which is subscribed to my SNS) or evidence it was called. Am I missing a step? Is there some easier way to do this?

Hi @misiakpjon

Welcome to the Auth0 Community!

What exactly are you seeing in the response?

It looks like the example AWS docs has this set up with a promise.

1 Like

I was not able to get any of the SNS examples working, so I decided to use an API Gateway->Lambda instead of SNS->Lambda and was able to get that working very easily.

1 Like

Glad you were able to get that working. Thanks for the update!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.