Mukund Gandlur
Mukund Gandlur

Reputation: 869

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.

Upvotes: 5

Views: 1696

Answers (3)

Eduardo Oviedo Blanco
Eduardo Oviedo Blanco

Reputation: 455

Do it like this:

aws cognito-idp update-user-pool
  --user-pool-id <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>

Upvotes: 2

KingAndrew
KingAndrew

Reputation: 1165

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

Upvotes: 2

alessio
alessio

Reputation: 189

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>

Upvotes: 4

Related Questions