Python Lambda在后确认时触发时给出botocore.errorfactory.InvalidLambdaResponseException

问题描述

我已设置在AWS Cognito上触发的AWS Lambda函数。电子邮件确认成功后的触发器。 Lambda函数在Python3.6中。

我指的是Cognito postConfirmation触发器的AWS文档。 https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html

"response": {}

到目前为止,我尝试返回None,{},'{}'(空的json字符串)或有效的字典,例如{'status':200,'message':'the message string'},但它给出了错误。

botocore.errorfactory.InvalidLambdaResponseException: An error occurred (InvalidLambdaResponseException) when calling the ConfirmSignUp operation: Unrecognizable lambda output

后确认功能应该是什么有效回应? 这是代码的一部分。

from DBConnect import user

import json

def lambda_handler(event,context):

    ua = event['request']['userAttributes']
    print("create user ua = ",ua)
    if ('name' in ua):
        name = ua['name']
    else:
        name = "guest"
    newUser = user.create(
        name = name,uid = ua['sub'],owner = ua['sub'],phoneNumber = ua['phone_number'],email = ua['email']
    )
    print(newUser)
    return '{}' #  <--- I am using literals here only.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)