jugglingcats
jugglingcats

Reputation: 749

AWS Cognito and Lambda trigger - any way to specify the Lambda version?

I've read the previous answer here: AWS: specify Lambda version for Cognito trigger, but it's a couple of years ago and I really hope something's changed!

I just can't believe this is the state of things. Am facing the prospect that deploying changes to my dev and test Lambda stages will break production because Cognito will always call the $LATEST version of my lambda. Please say it's not true!

Thanks

Upvotes: 0

Views: 686

Answers (1)

alessio
alessio

Reputation: 189

It's possible replicating the same behavior that is done for $LATEST by picking a lambda in user pool triggers configuration, via CLI: lambda arn with alias syntax needs to be configured for a trigger and an InvokeFuncion permission needs to be added.

aws lambda add-permission --function-name arn:aws:lambda:_awsregion_:_awsid_:function:_functionname_:_alias_ --statement-id _uuid_ --action lambda:InvokeFunction --principal cognito-idp.amazonaws.com --source-arn arn:aws:cognito-idp:_awsregion_:_awsid_:userpool/_awsregion_id_
aws cognito-idp create-user-pool --user-pool-id _awsregion_id_ --lambda-config CustomEmail=arn:aws:lambda:_awsregion_:_awsid_:function:_functionname_:_alias_

See https://docs.aws.amazon.com/cli/latest/reference/lambda/add-permission.html and https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/create-user-pool.html for full reference.

Upvotes: 3

Related Questions