微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将 Lambda 触发器附加到 Cloudformation 中的 Cognito 用户池

如何解决将 Lambda 触发器附加到 Cloudformation 中的 Cognito 用户池

我希望自定义当您拨打 admincreateuser() 时 Cognito 发送给新用户的电子邮件消息

我可以看到您通过 Lambda 函数执行此操作,例如 -

https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html

exports.handler = (event,context,callback) => {
    if(event.userPoolId === "theSpecialUserPool") {
        if(event.triggerSource === "CustomMessage_Admincreateuser") {
            event.response.smsMessage = "Welcome to the service. Your user name is " + event.request.usernameParameter + " Your temporary password is " + event.request.codeParameter;
            event.response.emailSubject = "Welcome to the service";
            event.response.emailMessage = "Welcome to the service. Your user name is " + event.request.usernameParameter + " Your temporary password is " + event.request.codeParameter;
        }
    }
    callback(null,event);
};

我还可以看到 AWS::Cognito::UserPool一个 LambdaConfig 对象,带有一个 CustomMessage 字段

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-lambdaconfig.html

看起来这是附着点:)

然而我看不到的是精确的附着机制:(

CustomMessage 字段定义很神秘 -

CustomMessage

A custom Message AWS Lambda trigger.

required: No
Type: String
Minimum: 20
Maximum: 2048
Pattern: arn:[\w+=/,.@-]+:[\w+=/,.@-]+:([\w+=/,.@-]*)?:[0-9]+:[\w+=/,.@-]+(:[\w+=/,.@-]+)?(:[\w+=/,.@-]+)?

Update requires: No interruption

即它只是一个 String - 但它是 String

  • 一个 ARN ?
  • Ref ?
  • 内联 Lambda 主体声明?

有谁知道 LambdaConfig.CustomMessage 绑定支持上述哪种格式?

解决方法

根据字符串值 CustomMessage 的验证模式,它似乎支持 ARN,因为字符串必须包含 arn

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。