Pass Cloudwatch Event Data to Lambda Function

0

Is there an example for how to structure the Lambda function to use data that is passed from a triggered Cloudwatch event.

I have my Lambda function as the target of the event, and I have matched event as the input. but I do not know how to take one of those fields and make it a usable variable.

질문됨 2년 전2204회 조회
2개 답변
1

There is a Java example here - https://github.com/awsdocs/aws-lambda-developer-guide/tree/main/sample-apps/java-events

This example shows how different types of events can be handled in lambda and Cloudwatch Events is one of the examples.

Note that Cloudwatch events has now been integrated into a service called Eventbridge

There is a good AWS workshop that provides good hands-on practice with Eventbridge over here - https://catalog.us-east-1.prod.workshops.aws/workshops/63320e83-6abc-493d-83d8-f822584fb3cb/en-US

This particular section https://catalog.us-east-1.prod.workshops.aws/workshops/63320e83-6abc-493d-83d8-f822584fb3cb/en-US/lambda in the above workshop shows lambda integration with Eventbridge

There is also a tutorial in the AWS documentation that shows how to integrate Lambda with Eventbridge over here - https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-run-lambda-schedule.html

profile pictureAWS
전문가
답변함 2년 전
0

Hello,

Using SNS as a trigger to the Lambda function for the CloudWatch Event. It provides a message that is sent to a SNS Topic. When the SNS triggers the Lambda Function, the message event can be obtained by a Lambda code. From that you can tap into the message dictionary and get the values needed.

The below link shows how you can get the message from the SNS topic

https://docs.aws.amazon.com/lambda/latest/dg/with-sns-create-package.html#with-sns-example-deployment-pkg-python

답변함 2년 전
  • Cloudwatch Events (now merged into Eventbridge) can directly be consumed by lambda, without having to go through SNS. What extra value is SNS adding, unless the customer wants to send out emails or SMS messages?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠