GithubHelp home page GithubHelp logo

deliverr / data-kinesis-s3-recovery Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 1.0 11 KB

Recovers Kinesis Firehose source records from S3, replaying them into the stream

License: MIT License

Python 94.51% Shell 5.49%
aws-lambda aws-kinesis aws-s3

data-kinesis-s3-recovery's Introduction

kinesis-s3-recovery

Recovers Kinesis Firehose source record backups from S3, replaying them into the stream.

Installation

The python scripts make use of python 3 and boto3. pipenv install or pip install boto3 will do.

Deployment

A package.sh shell script will create a lambdas.zip that can be uploaded to AWS Lambda. The function handlers are:

  • queue_firehose_s3_backups.main
  • recover_firehose_s3_backup.main

The lambda functions will need an IAM role that has permissions to:

  • Read from S3
  • Put to Kinesis Firehose
  • Send and receive messages from SQS

Functions

Files are recovered in two steps, with two lambda functions:

  1. queue_firehose_s3_backups.py lists all the files in the S3 source records backup and SQS queues each file
  2. recover_firehose_s3_backup.py is triggered by the SQS queue. It parses objects from each file and puts records to the Kinesis Firehose stream

Test

With the lambda functions deployed, they can be tested with an event like the following

queue_firehose_s3_backups.py

{
  "bucket": "my-s3-bucket",
  "prefix": "is/optional/",
  "queue_url": "https://sqs.us-east-1.amazonaws.com/123456789/my_queue.fifo",
  "kinesis_stream": "my-kinesis-stream"
}

The file is assumed to be formatted in the idiosyncratic Kinesis Firehose manner, with objects concatenated together.

Credits

Thanks to Tom Chapin for the code to parse the Kinesis Firehose S3 record format: https://stackoverflow.com/questions/34468319/reading-the-data-written-to-s3-by-amazon-kinesis-firehose-stream

License

MIT

data-kinesis-s3-recovery's People

Contributors

emurphy avatar nadia-virjee avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

leeroygroup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.