Aws lambda 如何将验证代码传递给Lambda函数

Aws lambda 如何将验证代码传递给Lambda函数,aws-lambda,amazon-cognito,Aws Lambda,Amazon Cognito,我正在尝试自定义AWS Cognito在用户忘记密码时发送的电子邮件 它需要{#####}占位符作为电子邮件中的验证代码。例如,如果你 event['response']['emailMessage']=“您的代码是{{}”,您将收到一条消息您的代码是123456 下面是我的AWS Lambda函数的一个示例: def自定义消息处理程序(事件、上下文): 事件['response']['emailSubject']='Custom subject' 事件['response']['emailMe

我正在尝试自定义AWS Cognito在用户忘记密码时发送的电子邮件

它需要{#####}占位符作为电子邮件中的验证代码。例如,如果你
event['response']['emailMessage']=“您的代码是{{}”
,您将收到一条消息
您的代码是123456

下面是我的AWS Lambda函数的一个示例:

def自定义消息处理程序(事件、上下文):
事件['response']['emailSubject']='Custom subject'
事件['response']['emailMessage']='Custom email'
#验证代码=事件[…]???
返回事件

看起来Cognito在lambda返回带有占位符的消息后生成了验证代码。是否可以在lambda中获取验证代码以使用它?

Amazon Cognito的自定义消息lambda触发器的事件JSON没有获取数字验证代码。触发器可用的事件数据,如中所述,如下所示:

{
  "version": 1,
  "triggerSource": "CustomMessage_AdminCreateUser",
  "region": "<region>",
  "userPoolId": "<userPoolId>",
  "userName": "<userName>",
  "callerContext": {
      "awsSdk": "<calling aws sdk with version>",
      "clientId": "<apps client id>",
      ...
  },
  "request": {
      "userAttributes": {
          "phone_number_verified": false,
          "email_verified": true,
           ...
      },
      "codeParameter": "####",
      "usernameParameter": "username"
  },
  "response": {
      "smsMessage": "<custom message to be sent in the message with code parameter and username parameter>"
      "emailMessage": "<custom message to be sent in the message with code parameter and username parameter>"
      "emailSubject": "<custom email subject>"
  }
}
{
“版本”:1,
“triggerSource”:“CustomMessage\u AdminCreateUser”,
“区域”:“,
“userPoolId”:“”,
“用户名”:“”,
“callerContext”:{
“awsSdk”:“,
“clientId”:“,
...
},
“请求”:{
“用户属性”:{
“电话号码已验证”:假,
“电子邮件已验证”:正确,
...
},
“codeParameter”:“####”,
“usernameParameter”:“用户名”
},
“答复”:{
“smsMessage”:”
“电子邮件”:”
“电子邮件主题”:”
}
}

只有在事件中有Cognito数据可用,或者有单独的API调用时,才能在Lambda触发器中使用Cognito数据。但考虑到亚马逊Cognito的设计,这似乎是不可能的

Amazon Cognito的自定义消息Lambda触发器的事件JSON没有获得数字验证码。触发器可用的事件数据,如中所述,如下所示:

{
  "version": 1,
  "triggerSource": "CustomMessage_AdminCreateUser",
  "region": "<region>",
  "userPoolId": "<userPoolId>",
  "userName": "<userName>",
  "callerContext": {
      "awsSdk": "<calling aws sdk with version>",
      "clientId": "<apps client id>",
      ...
  },
  "request": {
      "userAttributes": {
          "phone_number_verified": false,
          "email_verified": true,
           ...
      },
      "codeParameter": "####",
      "usernameParameter": "username"
  },
  "response": {
      "smsMessage": "<custom message to be sent in the message with code parameter and username parameter>"
      "emailMessage": "<custom message to be sent in the message with code parameter and username parameter>"
      "emailSubject": "<custom email subject>"
  }
}
{
“版本”:1,
“triggerSource”:“CustomMessage\u AdminCreateUser”,
“区域”:“,
“userPoolId”:“”,
“用户名”:“”,
“callerContext”:{
“awsSdk”:“,
“clientId”:“,
...
},
“请求”:{
“用户属性”:{
“电话号码已验证”:假,
“电子邮件已验证”:正确,
...
},
“codeParameter”:“####”,
“usernameParameter”:“用户名”
},
“答复”:{
“smsMessage”:”
“电子邮件”:”
“电子邮件主题”:”
}
}

只有在事件中有Cognito数据可用,或者有单独的API调用时,才能在Lambda触发器中使用Cognito数据。但考虑到亚马逊Cognito的设计,这似乎是不可能的

遗憾的是,无法在Lambda函数中使用数字验证代码。@lightyagami您可以将注释作为答案发布。遗憾的是,无法在Lambda函数中使用数字验证码。@lightyagami您可以将您的评论作为答案发布。感谢您的澄清谢谢您的澄清