Cognito trigger wrong lambda event - aws-lambda

I'm using UpdateUserAttributes (AWS JAVA SDK) to update the user email. However, I'm not using the default email sender from Cognito but I'm using the custom email sender which will trigger the Lambda function. I'm facing two issues:
Based on AWS documentation: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-email-sender.html
The trigger source value should be "CustomEmailSender_UpdateUserAttribute" but the value that I see in the cloud watch is always "CustomEmailSender_VerifyUserAttribute".
I added the key-value to the clientMetaData but on the lambda request payload, the clientMetaData is always null.
Does anyone have to face these issues? and how did you bypass it?

Related

Is there any webhook support or do we get any notification for new function created in AWS Lambda

We did check AWS Lambda create function https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html.
We need help to know if there is any webhook support or do we get any notification when new function created in AWS Lambda.
Kindly help me know more on this. TIA !!!
Take a look at AWS CloudTrail. It logs all actions performed in your AWS account. You should be able to create an SNS notification for Lambda creation, then hook up that notification to whatever you want to happen.
I'm not sure whether CloudTrail will capture creation of Lambda's from CloudFormation, but I'm assuming you don't want to alert on that anyway.

AirBNB style email masking service implementation with AWS Lambda

I am building a small service application where users can cloak their email addresses using the service. Users who register to the website will have a unique email address to communicate with. I have tried to implement this relay service but i am stuck implementing it.
What i have tried
Catch all the emails coming for the domain with SES receiving rules and saving to the s3 bucket
Trigger lambda function to retrieve the original address of the designated user by calling an api call providing the email address user wanted to contact.
After a successful call the api call returns the original (unmasked) email address for lambda to forward the email to
Question: Is this an overkill when dealing with 1000s of emails handled like this ? Is there any way that you had implemented such as this ?
*AirBnB style communication

How to send a notification to a specific device using Amplify notification

I sat up notification following this doc https://docs.amplify.aws/lib/push-notifications/getting-started/q/platform/js.
I can register a token on Amazon pinpoint service.
My application is a chat app, so every time someone sends a message to someone, I want to send a notification to a specific device who receives the message. My question is How I can do this ? My user message data are stored in DynamoDB. So trigger Lambda function after put operation would be a good idea but I am not sure this is the solution.

Serverless deployed lambda not invoking callbacks.

I am pretty new to serverless and I have come across a bizarre situation. I have created a lambda function which lists the users from the cognito user pool. I have used cognitoidentityserviceprovider.listUsers to get the user list from user pool.
I tried creating the lambda function using serverless framework. Everything works fine but the callback for listUsers is never triggered.There are no error logs in cloudwatch and nothing happens until it gets timed out. I tired creating a test function from lambda console directly and used the same code there and the test function works perfectly fine.I am getting the user list from the test function.
Can anyone please give me an idea of what is happening here. If you want any more info please let me know. I would be very happy to get it fixed. I don't want to have two mediums for handling the lambda function which I am currently having (both serverless framework as well as lambda console).
This happens because you're trying to call an asynchronous method from inside your Lambda.
When AWS calls your Lambda, it simply invokes the handler method specified when you deployed the lambda. When that method returns, AWS puts the container that ran your code to sleep until another request is received.
In this case, what happened was probably you called the cognito list users call which is asynchronous and your main method ran to completion before receiving a response on the callback. AWS then put the container to sleep, which killed the connection to cognito and so you never received the response.
Unless there's a synchronous variant of the cognito list users call, then you'll either have to figure out how to make the call block and wait for the response in your code, or find another way to call cognito.
Since cognito is an AWS service, I'm pretty sure you are simply using the wrong SDK or API call variant to interact with cognito from inside the lambda.

Can we pass custom values using square connect and have it returned back in webhook notification

I am looking for information on how to pass a custom variable (transaction_logID) to the square API and then have it returned back to me on the webhooks notification URL response.
How can i specifically link a "charge" event with a "notification" event so that I can update my personal SQL record with the transaction result? (Approved, Declined etc)
Thanks for your help.
Unfortunately passing in custom data and getting it back in a webhook isn't possible.
Depending on what exactly you want to link your notification to, you can look up the ID from the webhook in the v1 payments endpoints.

Resources