Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Amazon EventBridge to Amazon Kinesis

Created with SnapAmazon EventBridgeKinesis Datastreams

Create an EventBridge event bus and rule that publishes matched events to Amazon Kinesis.

This pattern creates an EventBridge event bus and rule that publishes matched events to Amazon Kinesis. In this example, the rule filters for specific attributes in the event before sending to the Kinesis Data Stream.

AWSTemplateFormatVersion: '2010-09-09'
Description: Sample template to deliver events from Amazon EventBridge to Kinesis Stream (uksb-1tthgi812) (tag:eventbridge-kinesis)

Resources:
  EventBus:
    Type: AWS::Events::EventBus
    Properties:
      Name: "test-bus"
      
  KinesisStream:
    Type: AWS::Kinesis::Stream
    Properties:
      Name: "test-stream"
      ShardCount: 1
      
  EventRule:
    Type: AWS::Events::Rule
    Properties:
      Name: "test-rule"
      EventBusName: !GetAtt EventBus.Arn
      Description: "Send matched events to Kinesis Data Stream"
      Targets: 
        - Arn: !GetAtt KinesisStream.Arn
          Id: "kinesis-stream-target"
          RoleArn: !GetAtt 
            - EventBridgeIAMrole
            - Arn
      EventPattern:
        source:
          - "my-application"
          
  EventBridgeIAMrole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service: !Sub events.amazonaws.com
            Action: 'sts:AssumeRole'
      Path: /
      Policies:
        - PolicyName: EventBridgeInvokeKinesis
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Action:
                  - "kinesis:PutRecord"
                  - "kinesis:PutRecords"
                Resource:
                  - !GetAtt KinesisStream.Arn
                  

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/eventbridge-kinesis

Deploy

sam deploy --guided


Testing

Use the AWS CLI to send a test event to EventBridge and observe the event delivered to the Kinesis Data Stream:
1. Send an event to EventBridge: aws events put-events --entries file://event.json
2. Monitor the event bus cloud watch metrics to check the target invocations. Similarly monitor the Kinesis Data Stream metrics to check if matched events are available.

Cleanup

Delete the stack: sam delete

Sangram Sonawane

Presented by Sangram Sonawane

Senior Solutions Architect, Amazon Web Services

Follow on LinkedIn