amazon-web-services - 当用户添加到用户池时,Cognito 启动 lambda

标签 amazon-web-services aws-lambda amazon-cognito amazon-cloudwatch

通过 EventBridge 规则将用户添加到用户池(任何一个)时是否可以触发 lambda?

最佳答案

可以在 CloudTrail 中记录 AWS Cognito,然后使用 EventBridge 根据来自 AWS Cognito 的 AWS CloudTrail API 中的调用来触发 lambda。

  1. 需要在 AWS CloudTrail 中设置跟踪,如 Logging Amazon Cognito API calls with AWS CloudTrail 中所述。
  2. 在 EventBridge 中,您可以从服务 AWS Cognito 用户池和 CloudTrail 中选择事件模式:

enter image description here

  • 您可以过滤单个操作要触发的 lambda,例如 AdminCreateUser
  • 过滤 lambda 触发器的支持操作列表,supported operations .

    您还可以在 AWS Cognito 中将 lambda 设置为触发器,以便对每个用户操作进行预注册或预身份验证,而不是使用 Event Bridge。

    如文档 Customizing user pool workflows with Lambda triggers 中所述:

    You can create an AWS Lambda function and then trigger that function during user pool operations such as user sign-up, confirmation, and sign-in (authentication) with a Lambda trigger. You can add authentication challenges, migrate users, and customize verification messages.

    要将 lambda 链接为 AWS Cognito 中的触发器:

    1. Create your lambda if does not exist.
    2. In AWS Cognito, choose an existing user pool from the list, or create a user pool.
    3. In your user pool, choose the Triggers tab from the navigation bar.
    4. Choose a Lambda trigger, such as Pre sign-up or Pre-authentication, and then choose your Lambda function (Created before in AWS Lambda) from the Lambda function drop-down list.
    5. Choose Save changes.

    关于amazon-web-services - 当用户添加到用户池时,Cognito 启动 lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70243226/

    相关文章:

    node.js - 将 Angular 2 应用程序部署到 EC2

    mysql - Spring Mysql 未在远程 IP 上正确使用 application.properties 文件数据

    node.js - 如何使用 Lambda 启动和停止 EC2 实例

    swift - 使用 Swift 验证 AWS Cognito token

    amazon-web-services - 如何备份 AWS Elasticache Redis 数据?

    linux - 如何在AWS Cli中查询嵌套值?

    javascript - AWS Lambda 函数在 IntentHandler 调用的函数完成之前返回

    python - 如何直接在 AWS Lambda 中导入 Google 模块?

    amazon-web-services - 如何在 lambda 函数中获取 cognito id?

    amazon-web-services - Terraform,从null_resource,local-exec和AWS CLI获取输出