Git Product home page Git Product logo

ukhomeoffice.dq-kube-gen-s3events-triggerlambda's Introduction

dq-kube-gen-s3events-triggerlambda

Repo to Generate S3 notification events for Files already in S3 and Trigger a Lambda that processes the events.

Docker Repository on Quay

Docker container that can generate S3 notifications events based on a range of last modified timestamps and Trigger a lambda passing that event as an input to the lambda function. Tasks include:

  • Reading Files in an S3 bucket based on a Prefix and suffix.
  • Filter files based on a time range.
  • Generate S3 notification events for these files(s3 objects)
  • Trigger a lambda function by passing the event data as an input.

Dependencies

  • Docker
  • Python3.7
  • Drone
  • AWS CLI
  • AWS Keys with GET access to S3 and Invoke access on AWS Lambda.
  • Kubernetes

Example usage

Running in Docker

Build container

docker build -t gens3events app/

Run container

docker run
-e LAMBDA_FUNC="arn:aws:lambda:eu-west-2:797728447925:function:api-kafka-input-test-trigger"
-e AWS_ACCESS_KEY_ID=ABCDEFGHIJLMNOP
-e AWS_SECRET_ACCESS_KEY=aBcDe1234+fghijklm01
-e AWS_DEFAULT_REGION=eu-west-2
-e S3_BUCKET="s3-dq-api-cdlz-msk-test"
-e LAST_MOD_DTTIME_START="2020-07-09 10:55:31"  
-e LAST_MOD_DTTIME_END "2020-07-09 13:55:31"
-e S3_PREFIX "parsed"
-e S3_SUFFIX "jsonl"
-e WAIT_SEC "60"
gens3events

Useful commands

Run a one time instance of the job:-

kubectl create job dq-athena-partition-maintenance --from=cronjob/dq-athena-partition-maintenance

Variables

See below a list of variables that are required, and also some that are optional

Variable name example description required
LAMBDA_FUNC arn:aws:lambda:eu-west-2:797728447925:function:api-kafka-input-test-trigger Lambda Function that should be triggered Y
WAIT_SEC 60 Seconds to wait before generating the next notifications and triggering the next lambda Y
S3_BUCKET s3-dq-api-cdlz-msk-test S3 bucket that contains files that need to be process file Y
LAST_MOD_DTTIME_START 2020-07-09 10:55:31 Starting range of Last Modified date time for files that need reprocessing Y
LAST_MOD_DTTIME_END 2020-07-09 10:55:31 End of the range of Last Modified date time for files that need reprocessing Y
AWS_ACCESS_KEY_ID ABCD AWS access key ID Y
AWS_SECRET_ACCESS_KEY ABCD1234 AWS secret access key Y
AWS_DEFAULT_REGION eu-west-2 AWS default region Y

Drone secrets

Environmental variables are set in Drone based on secrets listed in the .drone.yml file and they are passed to Kubernetes as required.

Running the build

This repo will generate events for environments independently. If you want to run Events for notprod, make a branch with the prefix notprod/. If you want to run Events for prod, make a branch with the prefix prod/. Once you make a branch the change will be LAST_MOD_DTTIME_START and LAST_MOD_DTTIME_END to that which you specify. Commit your branch and push, this will trigger the build in the respective environment.

ukhomeoffice.dq-kube-gen-s3events-triggerlambda's People

Contributors

abouhouly avatar jwanderema avatar sidaker avatar

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.