Slide 1

Slide 1 text

Using event filtering on Lambda triggers Jones Zachariah Noel N

Slide 2

Slide 2 text

About me https://zachjonesnoel.com 👋 I’m Jones Zachariah Noel N (zachjonesnoel) 🥑 Senior Developer Advocate @ Freshworks ☁ AWS Serverless Hero ⚡ Serverless architect 🚀 AWS UG Bengaluru co-organizer 󰞵 Runs newsletter / blog on The Serverless Terminal

Slide 3

Slide 3 text

Agenda ⚡Look into how Lambda triggers work ⚡Dive into Event filtering on Lambda triggers ⚡Demo

Slide 4

Slide 4 text

AWS Lambda function triggers Synchronous Asynchronous Poll based

Slide 5

Slide 5 text

AWS Lambda function triggers

Slide 6

Slide 6 text

Event filtering Targeted invocation Cost effective Filter expression check Poll based mechanism

Slide 7

Slide 7 text

Understanding event filtering

Slide 8

Slide 8 text

Event filtering supported services DynamoDB Streams Amazon SQS Kinesis Data Streams Amazon MQ Amazon MSK and self managed Apache Kafka

Slide 9

Slide 9 text

Event filtering supported services DynamoDB Streams Amazon SQS Kinesis Data Streams Amazon MQ Amazon MSK and self managed Apache Kafka dynamodb body data data value

Slide 10

Slide 10 text

Event filter expressions

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Event filter expressions (console)

Slide 14

Slide 14 text

Event filter expressions (SAM template) Events: DynamoDBTable: Type: DynamoDB Properties: Stream: !GetAtt DynamoDBTable.StreamArn StartingPosition: TRIM_HORIZON BatchSize: 100 FilterCriteria: Filters: # Filter pattern to check only inserted action on DynamoDB with the item_type being THREAT - Pattern: '{"eventName": ["INSERT"],"dynamodb":{"NewImage":{"item_type":{"S": [ "THREAT" ]}}}}' # Filter pattern to check only deleted action on DynamoDB - Pattern: '{"eventName": ["REMOVE"]}'

Slide 15

Slide 15 text

Event filter expressions (AWS CLI)

Slide 16

Slide 16 text

● Only the events which match the pattern invoke Lambda fn. ● No additional cost, in-fact cost effective. ● Manual comparison of events patterns. ● Additional times of code. ● Unnecessary invocation of Lambda fn.

Slide 17

Slide 17 text

● https://blog.theserverlessterminal.com/trigger-lambda-functions-with-event-filtering ● https://blog.theserverlessterminal.com/deep-dive-into-lambda-event-filters-for-dyanmo db ● https://aws.amazon.com/about-aws/whats-new/2021/11/aws-lambda-event-filtering-am azon-sqs-dynamodb-kinesis-sources/ ● https://github.com/zachjonesnoel/event-filtering-with-dynamo-streams Resources

Slide 18

Slide 18 text

Thank you! https://zachjonesnoel.com @zachjonesnoel zachjonesnoel zachjonesnoel jones-zachariah-noel-n https://theserverlessterminal.com https://blog.theserverlessterminal.com