사후 확인에서 트리거 될 때 botocore.errorfactory.InvalidLambdaResponseException을 제공하는 Python Lambda

Aug 24 2020

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.

답변

2 kerasbaz Aug 23 2020 at 23:54

이벤트 개체를 반환해야합니다.

return event

이는 문서에서 제공하는 예제에서 명확하지 않습니다. 이벤트 객체에 응답 키가 포함되어 있는지 확인하고 확인할 수 있습니다.