Purpose:
My goal is to add items into dynamo using a lambda function, which then will set off another lambda trigger that will send a SNS notification.
The first lambda function successfully adds in items into Dynamo. However the second lambda trigger is not sending SNS notifications.
However, I did a JSON test event for the second lambda trigger and it was then successfully able to send a sns notification. So, theres is something wrong with dynamo and the second lambda function.
In DynamoDB, under 'DynamoDB stream details' where I enabled the lambda tigger I get an error 'PROBLEM: Function call failed'
Related
I want the Lambda function to be triggered every 10 minutes and the function to receive an event in the form of JSON from EventBridge. The event will contain a Document ID which will be used in the Lambda code. Currently, the EventBridge does not have the feature to send custom events to target for Rule Type Schedule. The custom event here is the Document ID which I want the Lambda function to receive as an event. How can I achieve this?
It appears that your goal is:
Trigger an AWS Lambda function every n minutes
Pass static information in the event that will be received by the Lambda function
You can do this when configuring the target for a scheduled event:
Select the Lambda function as a target
In Additional Settings select "Configure target input" and Constant (JSON text)
The event will then be available in the Lambda function via the event parameter:
Is it possible to create a lambda which is triggered manually to read from an SQS.
I have an SQS queue which is constantly receiving messages, I want to process them when I want to (not continuous sync processing).
Can I have something like a start/stop lambda, where I start the lambda, and it consumes actively from SQS and when I stop it stops consuming
Normally, an AWS Lambda function is configured to "trigger" from an Amazon SQS queue. Whenever a message arrives, a Lambda function would be triggered.
However, instead of configuring a trigger, you could code an AWS Lambda function to call ReceiveMessages() on the queue itself. The Lambda function would then be responsible for calling DeleteMessage() after the message has been processed.
You can invoke a Lambda function at any time by using the Invoke() command.
The only decision you would need to make is whether the Lambda function should process:
One message per invocation, or
One batch of messages (up to 10) per invocation, or
Run a loop that keeps retrieving messages from the queue until the queue is empty or until the Lambda function times-out (which could leave a message partially processed, so it isn't a good idea)
I am trying to trigger my lambda function from SQS delay queue and it is triggering lambda but no message in queue. Even when I check on aws console there is a message delay and when that delay time is over. It trigger my lambda function but when my lambda try to get the list of messages it shows empty list. The other thing is when I remove the lambda trigger after that whenever I send a message to queue it shows message available after the delay time. So it's working as expected without adding a trigger to lambda but when I add trigger my lambda is not receiving any message to process.
I have tried various things but nothing worked out. my Default Visibility Timeout: 30seconds and Receive Message Wait Time: 0 seconds and Delivery Delay: 10 seconds.
Using below code to fetch the messages from sqs and it always return empty list :
final ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(SQS_URL);
final List<Message> messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
I am new to aws and don't know what to do, due to this issue stuck in a deadlock. Please help.
If you have configured the Amazon SQS queue to trigger an AWS Lambda function, then the function should not call ReceiveMessage().
Instead, the message is automatically taken from the SQS queue and is passed to the Lambda function via the event parameter.
For sample code, see: Sample Amazon SQS Function Code - AWS Lambda
The Lambda function should loop through the messages passed to the function. When the function ends, the messages will automatically be deleted.
I have created SQS Queue and event source mapping that triggers lambda function on receiving message. All this works fine and I am doing through aws java sdk.
Now I want to return value from Lambda function. How will I be able to access it as I am calling Lambda function only through SQS.Any help is appreciated
Below is my handler method structure:
public String handleRequest(SQSEvent event, Context context) {
.....
....
return "something"
}
This is not possible because the that sends a message to Amazon SQS completes once the message is sent. This allows the queue to be used to decouple services. In fact, a message could sit in an SQS queue for up to 14 days.
While the SQS queue will trigger the AWS Lambda function very quickly, there is still no concept of a "return" value from the Lambda function if it is triggered from an SQS message.
If you wish to trigger Lambda and wait for a response, you can directly invoke the Lambda function and await a response. This would not involve the use of SQS.
I have a AWS Lambda that is running every minute. It will either succeed or pass. I have a AWS Alarm that is monitoring this Lambda and going into an ALERT or SUCCESS state based on the Lambda execution. When the Alarm state changes a SNS message is fired off an another Lambda is triggered. This Lambda uses a webhook and sends out a message.
Is there a way of getting the error message from the 1st Lambda to be viewed by the 2nd Lambda (and ultimatley passed to the webhook)? I can see the error message on the CloudWatch logs.
Any ideas on this would be great.
The reason I have a Alarm inbetween the 1st Lambda and the SNS is I only want a message when the state changes not every time the 1st Lambda runs.