【问题标题】:Attaching Lambda Triggers to a Cognito UserPool in Cloudformation将 Lambda 触发器附加到 Cloudformation 中的 Cognito UserPool
【发布时间】:2021-04-04 18:09:10
【问题描述】:

我希望自定义 Cognito 在您致电 adminCreateUser() 时向新用户发送的电子邮件

我可以看到您通过 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绑定支持上述哪种格式吗?

【问题讨论】:

    标签: amazon-cloudformation amazon-cognito


    【解决方案1】:

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

    【讨论】:

    • @Justin 不用担心 :)
    猜你喜欢
    • 2017-08-13
    • 1970-01-01
    • 2019-01-30
    • 2021-08-01
    • 2018-07-05
    • 2023-01-01
    • 2019-12-10
    • 2020-03-19
    • 1970-01-01
    相关资源
    最近更新 更多