Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda function on cognito login is not working for first time

I attached lambda function to my user pool.

When i am creating the user pool first time using terraform, it is not working with error: "Lambda function: AccessDenied"

If I remove the lambda function and reattach it, it is working fine.

Any clue why this is happening?

like image 776
Jayesh Dhandha Avatar asked Aug 26 '26 14:08

Jayesh Dhandha


1 Answers

Solved with below!!

Reference: https://forums.aws.amazon.com/thread.jspa?messageID=804779&#804779

If you associate a Lambda function through CLI, then you have to call the AddPermission API on that function to grant Amazon Cognito permissions to be able to invoke it. You can use the following parameters

"Action": "lambda:InvokeFunction", "Principal": "cognito-idp.amazonaws.com", "SourceArn": "", "StatementId": "Any string you like"

http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html

like image 174
Jayesh Dhandha Avatar answered Aug 29 '26 13:08

Jayesh Dhandha