在AWS Cognito用户池上删除用户后触发Lambda函数 [英] Triggering a Lambda function upon deleting a user on AWS Cognito User Pool

查看:125
本文介绍了在AWS Cognito用户池上删除用户后触发Lambda函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS Cognito用户池具有一些预定义的事件来处理用户注册,确认等。完整列表为此处

AWS Cognito User Pools have some pre-defined events to handle user signup, confirmation etc. The full list is here.

但是,删除用户没有明显的触发条件。

However, there is no apparent trigger for deleting a user.

因此,从Cognito用户池中删除用户时,有什么方法可以触发Lambda函数(当然,使用用户名和/或电子邮件地址之类的参数) ?

So, is there any way one can trigger a Lambda function when a user is deleted from Cognito User Pool (of course, with arguments like username and/or email address)?

推荐答案

如果您使用的是 Amazon Cognito Sync:

当数据集同步时,Amazon Cognito引发同步触发事件。您可以使用同步触发器事件在更新或删除用户时执行操作。
请查看下面的官方文档以了解更多信息和步骤。

Amazon Cognito raises the Sync Trigger event when a dataset is synchronized. You can use the Sync Trigger event to take an action when a user is updated or deleted. Please have a look on below official document for more information and steps.

参考: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-events.html


由应用程序用户更新的记录会将 op字段设置为替换,而删除的记录会将 op字段设置为

Records updated by the app user will have the 'op' field set as "replace" and the records deleted will have 'op' field as "remove".

根据参考文档op字段中的上述内容,可以帮助您识别操作,因此,如果在然后,您可以根据业务逻辑要求执行操作。

According to above point in referenced documentation op field can help you to identify operation, So if value is "removed" in op then you can perform your actions for your business logic requirement.

如果您不使用 Amazon Cognito Sync:


  1. 使用发布确认Lambda触发器

  2. 基于DynamoDB表 user构建您自己的用户列表。

  3. 构建您自己的用户

  4. 您应该使用lambda函数处理从cognito&中删除用户的操作。还有您要执行的业务逻辑。

  1. Create user records in DynamoDB table "user" using Post Confirmation Lambda Trigger.
  2. Build your own user listing based on DynamoDB table "user".
  3. Build your own user delete api using lambda function and aws api gateway.
  4. You lambda function should handle delete user from cognito & also your business logic that you want to perform.

这篇关于在AWS Cognito用户池上删除用户后触发Lambda函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆