send email when user registers - AWS Cognito federated Identities

我与影子孤独终老i 提交于 2019-12-05 16:55:28

So this is something which is not currently supported in Cognito out of the box. You are correct in saying that the only built in Cognito Event that will trigger a Lambda Function is the "Sync Trigger" Event. This Sync event is fired every time that a Cognito IdentityId Synchronizes some of their data to the Cognito Sync cloud data store.

This event is unrelated to the creation of a new IdentityId by Cognito Federated Identity.

You could in theory:

  • Run a list-identities call on the IdentityPool, before the user logs in.
  • Login the user. Check whether the IdentityId which has been given to the user is present in the list you retrieved before they logged in. This would tell you whether or not the identity that they were given existed before this login.
  • Based on this information you could make a decision whether or not to programatically call the Lambda Function from your application.

The setup of the above would be complex, as for security reasons you would need to maintain this service, server-side. The list-identities call requires AWS credentials to call. And I doubt you'd want to include permissions for that call in your IAM policy for unauthenticated users.

Aside from the above there is not much you can do at the moment. In order to do this, you would need to setup a DynamoDB table (or some similar low latency datastore) where you could maintain the state of the IdentityId list, and then query this service/store whenever you login a user to compare new logins to the pre-existing list.

If this is critical to your use case I would suggest heading over to AWS Support, and create a case where you can log this as a feature request.

https://aws.amazon.com/premiumsupport/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!