Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito - get user's sub in Lambda Trigger function

Does someone know if it is possible in aws Cognito to get the user's 'sub' in one of the Lambda Trigger functions you can use? (especially in Pre Sign-Up or Post Confirmation)

Since it is recommended to use the 'sub' attribute as primary key it would be great to have access to it.

Thank you!

like image 482
Björn Avatar asked Oct 22 '25 05:10

Björn


1 Answers

You can refer to this file for event structs. It's in golang, however, the same struct should be there for other languages.

Then you can retrieve the sub attribute from userAttributes object. Other fields (e.g. cognito:user_status, email, email_verified, name) could be used based on your requirement.

like image 84
sayboras Avatar answered Oct 24 '25 21:10

sayboras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!