配置Cognito以正确的方式通过第三方(例如SendGrid)发送电子邮件 [英] Configure Cognito to send emails through third party such as SendGrid the proper way

查看:64
本文介绍了配置Cognito以正确的方式通过第三方(例如SendGrid)发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试调用自定义消息功能来通过SendGrid发送电子邮件,效果很好,但是我没有办法阻止AWS通过他们的电子邮件发送.我试图将 messageAction 设置为"SUPPRESS",但是又出现了另一个问题.由于 messageAction 仅用于adminCreateUser函数,因此不支持这种自注册功能.我错过了什么还是做不正确吗?

I have tried to invoke the custom message function to send emails through SendGrid, well it worked but I don't have a way to stop AWS from sending through their emails. I have tried to set the messageAction to "SUPPRESS" but another problem arises. There is no such support for self-registration since messageAction is only for adminCreateUser function. Did I miss something or am I not doing this properly?

推荐答案

Custom Sender Lambda Triggers is the way to use 3rd party notification service providers.

目前缺少Cognito文档(缺少步骤,从示例复制后必须修复Lambda代码,没有有关如何使用CloudFormation进行部署的说明,...).

Cognito docs are lacking at the moment (steps are missing, Lambda code has to be fixed after copying from the example, no instructions of how to deploy with CloudFormation, ...).

步骤的高级概述:

  1. 创建对称的KMS密钥.
  2. 创建Lambda函数.向Lambda授予 kms:Decrypt 密钥的权限.将密钥ARN传递为环境变量.
  3. 创建用户池和用户池客户端.对于该池,配置提供Lambda和KMS密钥ARN的 LambdaConfig .
  4. 在代码中,使用在env变量中传递的密钥解密通知代码.
  5. 使用第三方(例如Twilio Sendgrid)API发送通知代码.
  1. Create a symmetric KMS key.
  2. Create a Lambda function. Grant Lambda permission to kms:Decrypt the key. Pass the key ARN as the environment variable.
  3. Create a User Pool and a User Pool Client. For the pool, configure LambdaConfig providing Lambda and KMS Key ARNs.
  4. In the code, decrypt the notification code using the key passed in the env variables.
  5. Send the notification code using the 3rd party (e.g. Twilio Sendgrid) API.

工具(截至2021年3月):

  • Cognito控制台不支持新触发器
  • AWS CLI支持新的触发器
  • CloudFormation文档说不支持触发器,但实际上它可以工作
  • Terraform还不支持设置新触发器(有一种解决方法)

我已经在博客中介绍了使用CloudFormation和Terraform设置自定义电子邮件Lambda触发器的过程:

I've blogged about the process of setting up the Custom Email Lambda Trigger with CloudFormation and Terraform: Send AWS Cognito emails with 3rd party ESPs.

这篇关于配置Cognito以正确的方式通过第三方(例如SendGrid)发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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