Skip to content

Instantly share code, notes, and snippets.

@htimur
Created February 26, 2023 12:05
Show Gist options
  • Save htimur/c42647ffd35d679a746079667995b6ff to your computer and use it in GitHub Desktop.
Save htimur/c42647ffd35d679a746079667995b6ff to your computer and use it in GitHub Desktop.
Kinesis consumer lambda example
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Kinesis Data Stream to AWS Lambda with Enhanced Fanout via a consumer
Resources:
# Define an AWS Kinesis Data Stream
KinesisStream:
Type: "AWS::Kinesis::Stream"
Properties:
ShardCount: 80
# Define and attach a consumer to the Kinesis Data Stream
ApplicationConsumer:
Type: "AWS::Kinesis::StreamConsumer"
Properties:
StreamARN: !GetAtt KinesisStream.Arn
ConsumerName: ApplicationConsumer
# Create SQS queue as a failure queue
StreamsFailureDLQ:
Type: AWS::SQS::Queue
# Define an AWS Lambda and attach it to the application consumer
ApplicationFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Runtime: nodejs12.x
Handler: app.lambdaHandler
Tracing: Active
Events:
Stream:
Type: Kinesis
Properties:
Stream: !GetAtt ApplicationConsumer.ConsumerARN
StartingPosition: LATEST
BatchSize: 100
DestinationConfig:
OnFailure:
Destination: !GetAtt StreamsFailureDLQ.Arn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment