Giter VIP home page Giter VIP logo

logs2bigquery-lambda's Introduction

logs2BigQuery-lambda

An AWS lambda function to process AWS CloudFront logs and write them in to Google BigQuery. The function is primarily triggered when CloudFront creates an s3 object. CloudFront will periodically create objects several times in an hour containing all the log data for that time period.

Configuration

The lambda function handler is configured with a JSON file that gets baked in to the zip file during the build process. To create a new configuration for the lambda copy config.example.json to config.json and edit the file with the appropriate data.

cp config.example.json config.json

The Lambda will also require GCP service account credentials so it can write data into BigQuery. If this is a first time setup then a service account must be created in the appropriate GCP project. Follow this guide on how to create service accounts in GCP. Once created, it should have the role "BigQuery Data Editor". The JSON credentials should be placed in the build directory so they get built into the Lambda. The environment variable GOOGLE_APPLICATION_CREDENTIALS should contain the value of the path where the credentials are stored. Follow this guide for information on how to configure a Lambda functions environment variables.

Building

Create a virtualenv in the project directory and run the build script. It will produce as zip file that you will then upload to AWS.

python3 -m venv .
mkdir build
./build.sh

Upload to AWS

This step assumes you have the aws cli configured and you have the correct access policy in place to use the AWS lambda service. Run the following command to upload the lambda function to AWS.

aws lambda update-function-code --zip-file fileb://$PWD/logs2BigQuery-lambda.zip --function-name logs2BigQuery

Basic Testing

The Lambda has a test event configured which will simulate the event that triggers the Lambda. This test event is modified so that the Lambda will write log data to a test table.

logs2bigquery-lambda's People

Contributors

ziaunys avatar

Stargazers

Hyeok Namkung avatar Renato Beccia avatar

Watchers

Reid Vandewiele avatar Alex Dreyer avatar James Cloos avatar  avatar  avatar Cody Clements avatar Gillian Weisgram avatar  avatar

Forkers

isabella232

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.