AWS Lambda error on Cognito User Pool trigger

拜拜、爱过 提交于 2019-12-19 02:49:17

问题


I'm trying to insert a record into DynamoDB invoking "Pre sign-up" trigger of Cognito User Pool.

Lambda function is pretty simple for testing purposes but there is always an error in client application on AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool.signUp call

Use case 1

Lambda body:

console.log('Received event:', JSON.stringify(event, null, 2));

Result:

InvalidLambdaResponseException: Invalid lambda function output : Invalid JSON

Use case 2

Lambda body:

callback("null", "success");

Result:

InvalidLambdaResponseException: Invalid lambda function output : Invalid JSON

Use case 3

Lambda body:

new AWS.DynamoDB.DocumentClient().put(params, callback);

Result:

InvalidLambdaResponseException: Invalid cognito sign in version. Version should be 1

So, any ideas what might be wrong?

Could the latest error might be related to the beta status of Cognito User Pool?

P.S. I will provide more details if needed. Thanks in advance.


回答1:


You are doing this in node.js and the error indicates you are not returning the service expected event source.

You should call context.done() when your lambda function finishes execution. Also, in any of the trigger sources which Cognito User Pool service generates, you can only edit the "response" part of the the source. For example, "autoConfirmUser" flag in PreSignUp trigger source.

Look at the examples in our developer guide for more details on this.




回答2:


@user3479125 To do the same in python just return an event as is, or with modifications in datasets.

This code is supposed to run between the mobile device and cognito, so it can modify the event and it should return it back, so Sync event will finish successfully.

Some more explanations here




回答3:


Try returning callback("null", event);

This should solve your problem.



来源:https://stackoverflow.com/questions/37423865/aws-lambda-error-on-cognito-user-pool-trigger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!