我设置了在AWS Cognito上触发的AWS Lambda函数。成功的电子邮件确认触发。Lambda函数在Python 3.6中。
我指的是Cognito postConfirmation触发器的AWS文档。https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-post-confirmation.html
"response": {}
到目前为止,我已经尝试返回None、{}、"{}"(空json字符串(或有效的字典,如{‘status’:200、"message":"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.
您需要返回事件对象:
return event
这在文档中提供的示例中并不明显。您可能需要检查并确保事件对象确实包含响应键(它应该包含(。