How to send event from EventBridge to Lambda - amazon-web-services

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:

Related

DynamoDB Stream: Last Processing result: PROBLEM: Function call failed

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'

AWS CloudWatch events, reference a Lambda Function passing previously saved event

I have a lambda function which stops an RDS Database. To run this function it is only necessary call it using the stop saved event. Stop Saved Eveent
When I input my CloudWatch Rule rule, using the Targets -> Configure input, how could I generate an event to tell the lambda to execute my previously saved stop event.
Many thanks!
That stop event is just a test event that you created, for testing Lambda functions in your web browser. That saved event isn't something you can reference later from things like CloudWatch Rules.
To modify the CloudWatch event being sent to your Lambda function to conform to the format you need, you would have to create a CloudWatch Event Input Transformer

AWS Lambda destination Lambda not triggering

Background:
I'm developing a custom AWS github-webhook via Terraform. I'm using AWS API Gateway to trigger an AWS Lambda function that validates the GitHub webhook's sha256 signature from the request header. If the lambda function successfully validates the request, I want a child lambda function to be invoked via the async invocation destination feature provided by Lambda.
Problem:
Even though I've configured the async invocation with the target child Lambda function, the child function is not triggered when the parent Lambda function is successful. This is reflected in the fact that the child Lambda function's associated CloudWatch log group is empty.
Relevant Code:
Here's the Terraform configuration for the Lambda function destination:
resource "aws_lambda_function_event_invoke_config" "lambda" {
function_name = module.github_webhook.function_name
destination_config {
on_success {
destination = module.lambda.function_arn
}
}
}
If more code from the module is needed, feel free to ask in the comments. The entire source code for this module is here: https://github.com/marshall7m/terraform-aws-codebuild/tree/master/modules/dynamic-github-source
Attempts:
Made sure both parent/child Lambda functions have permission to create logs within their respective Cloudwatch log group (attached arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole policy to both)
Made sure the parent Lambda function has the correct permission to invoke the child function: "lambda:InvokeFunction", "lambda:InvokeAsync"
Setup async invocation for child lambda function for both success and failure parent Lambda runs (child function still not triggered)
Add API integration request parameter `{'X-Amz-Invocation-Type': 'Event'} as mentioned in: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html
For every attempt to fix this, I made sure to redeliver the request from the source (github webhook page) and not via the AWS Lambda console.
From your description it seems to me that you are invoking parent function synchronously. Lambda destinations are only for asynchronous invocations:
You can also configure Lambda to send an invocation record to another service. Lambda supports the following destinations for asynchronous invocation
So you have to execute your parent function asynchronously for your child function to be invoked.
Adding the API integration request parameter `{'X-Amz-Invocation-Type': 'Event'} as mentioned in: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html did the trick. I initially came to the conclusion that this solution doesn't work based on the fact that a new Cloudwatch log group stream wasn't created when I redelivered the github payload. As it turns out, when I took a closer look at the previous Cloudwatch log stream, I found out that Cloudwatch appends logs for retriggered invocations of the Lambda function to the previous associated Cloudwatch log stream.

Can AWS Scheduled Lambda run concurrently?

I have a Scheduled Lambda function (via CloudWatch event rule) which is triggered every minute.
This lambda picks up a request from SQS queue, process the parameters and triggers AWS step functions workflow.
Now, ONLY 1 Lambda function instance is running every minute. How can I trigger multiple (e.g. 10) concurrent Lambda functions like this?
One way I can think of is to create 10 Cloudwatch event rule which runs every 1 minute, but I am not sure if that is the right way of doing it. Also, if I use this way, 10 lambda would be called even if I don't have entries in my SQS queue.
You can use the lambda step function.
Event trigger first function. Then it will call multiple functions parallel.
Some useful links:
https://www.youtube.com/watch?v=c797gM0f_Pc
https://medium.com/soluto-nashville/simplifying-workflows-with-aws-step-functions-57d5fad41e59
since your lambda function fetching data from SQS so you can create event source mapping between lambda and SQS so whenever message published to SQS, your lambda function will invoke concurrently depending on number of messages in queue so you do not need to invoke lamnda from cloudwatch event

Trigger SNS at specified time

I have a Lambda function that takes a list of tasks to be run at the time specified. This time can vary.
I am using SNS to trigger another Lambda function that in turn runs the tasks.
These tasks need to be run at specified time. Is it possible to publish a message to SNS using Lambda at the specified time?
Or send the message to SNS, but SNS in turn triggers Lambda at the specified time?
Any option would do.
P.S. I know there is an option of using Cloud Watch events, but I do not want to use any more services.
It appears that your requirement is to trigger an AWS Lambda function at specific times.
This can be done by using Amazon CloudWatch Events, which can take a cron-like expression to run a Lambda function at desired time intervals or specific times. This functionality was originally in the Lambda console, but was moved to CloudWatch Events when more services added scheduling capabilities.
However, CloudWatch Events cannot trigger an Amazon SNS message. If you need SNS to trigger Lambda, then you'll need CloudWatch Events to trigger a Lambda function that sends a message to SNS (which then triggers Lambda functions). Obviously, it would be cleaner to avoid SNS altogether unless you specifically need to fan-out the message to multiple subscriptions/Lambda functions.