Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant set AWS cognito triggers using CLI

I am trying to set a lambda trigger on cognito for Auth Challenge using AWS-CLI, which involves DefinAuthChallenge, CreateAuthChallenge, VerifyAuthChallenge etc.

aws cognito-idp update-user-pool     --user-pool-id <>    --lambda-config DefineAuthChallenge=<lambda-function-arn>:<function_name>:<function_alias>  --lambda-config CreateAuthChallenge=<lambda-function-arn>:<function_name>:<function_alias> --lambda-config VerifyAuthChallengeResponse=<lambda-function-arn>:<function_name>:<function_alias>

After I run this only the last lambda trigger config remains and DefineAuthChallenge, CreateAuthChallenge configuration is lost.

Please help me understand how to configure the lambda triggers on Cognito using CLI. I cant do this through UI because the function alias does not appear on the UI. And so, AWS-CLI is my only option.

like image 681
Mukund Gandlur Avatar asked Mar 03 '23 19:03

Mukund Gandlur


2 Answers

As explained in reference, please concatenate multiple trigger options using commas

aws cognito-idp update-user-pool --user-pool-id <> --lambda-config DefineAuthChallenge=<lambda-function-arn>:<function_name>:<function_alias>,CreateAuthChallenge=<lambda-function-arn>:<function_name>:<function_alias>,VerifyAuthChallengeResponse=<lambda-function-arn>:<function_name>:<function_alias>
like image 151
alessio Avatar answered Apr 20 '23 00:04

alessio


I cant get @alessio answer to work. Setting them one at a time works but it wipes all the other settings.

Here we are with just commas separating my two triggers

aws cognito-idp update-user-pool --user-pool-id <pool-id> --lambda-config PreSignUp=arn:aws:lambda:us-east-1:<mynumbers>:function:registerStudent:prod, PreAuthentication=arn:aws:lambda:us-east-1:<mynumbers>:function:validateStudent:prod

I also wrapped the arn string with double quotes same response.

Here we go with JSON

aws cognito-idp update-user-pool --user-pool-id <pool-id> --lambda-config {"PreSignUp":"arn:aws:lambda:us-e
ast- 1:<mynumbers>:function:registerStudent:prod", "PreAuthentication":"arn:aws:lambda:us-east-1:<mynumbers>:function
:validateStudent:prod"}

For both of those attemps there is pretty much the same respone:

Unknown options: PreAuthentication:arn:aws:lambda:us-east-1:<mynumbers>:function:validateStudent:prod

The only difference being equal signs for the comma seperated vs colon for the JSON.

Has anyone been able to get this to work with two triggers?

-Andrew

like image 21
KingAndrew Avatar answered Apr 19 '23 22:04

KingAndrew