Code Monkey home page Code Monkey logo

terraform-aws-elb-logs-to-elasticsearch's Introduction

terraform-aws-elb-logs-to-elasticsearch

Send ELB logs from S3 bucket to ElasticSearch using AWS Lambda

This directory contains terraform module to send ELB logs from S3 bucket to ElasticSearch using AWS Lambda

Particularly it creates:

  1. Lambda function that does the sending
  2. IAM role and policy that allows access to ES
  3. S3 bucket notification that triggers the lambda function when an S3 object is created in the bucket.
  4. (Only when your Lambda is deployed inside a VPC) Securitygroup for Lambda function

Module Input Variables

Variable Name Example Value Description Default Value Required
es_endpoint search-es-demo-zveqnhnhjqm5flntemgmx5iuya.eu-west-1.es.amazonaws.com AWS ES fqdn without http:// None True
index elblogs Index to create. adds a timestamp to index. Example: elblogs-2016.03.31` elblogs False
doctype elb-access-logs doctype elb-access-logs False
region eu-west-1 AWS region eu-west-1 False
nodejs_version 8.10 Nodejs version to be used 8.10 False
prefix public- A prefix for the resource names, this helps create multiple instances of this stack for different environments False
s3_bucket_arn elb-logs The arn of the s3 bucket containing the elb logs None True
s3_bucket_id elb-logs The id of the s3 bucket containing the elb logs None True
subnet_ids ["subnet-1111111", "subnet-222222"] Subnet IDs you want to deploy the lambda in. Only fill this in if you want to deploy your Lambda function inside a VPC. False

Example

provider "aws" {
  region = "eu-central-1"
}

module "public_elb_logs_to_elasticsearch" {
  source        = "neillturner/elb-logs-to-elasticsearch/aws"
  version       = "0.1.0"

  prefix        = "public_es_"
  es_endpoint   = "test-es-XXXXXXX.eu-central-1.es.amazonaws.com"
  s3_bucket_arn = "arn:aws:s3:::XXXXXXX-elb-logs-eu-west-1"
  s3_bucket_id  = "XXXXXXX-elb-logs-eu-west-1"
}

module "vpc_elb_logs_to_elasticsearch" {
  source        = "neillturner/elb-logs-to-elasticsearch/aws"
  version       = "0.1.0"

  prefix        = "vpc_es_"
  es_endpoint   = "vpc-gc-demo-vpc-gloo5rzcdhyiykwdlots2hdjla.eu-central-1.es.amazonaws.com"
  s3_bucket_arn = "arn:aws:s3:::XXXXXXX-elb-logs-eu-west-1"
  s3_bucket_id  = "XXXXXXX-elb-logs-eu-west-1"
  subnet_ids    = ["subnet-d9990999"]
}

Deployment Package Creation

The zip file elb-logs-to-elasticsearch.zip was build from prithviraju/aws-elb-logs-to-elasticsearch

  1. On your development machine, download and install Node.js.

  2. Go to root folder of the repository and install node dependencies by running:

    npm install
    

    Verify that these are installed within the node_modules subdirectory.

  3. To fix an issue with the module node-elb-log-parser causing errors

    TypeError: Cannot read property 'split' of undefined
    

    manually apply fix: TypeError: Cannot read property 'split' of undefined #6 #7

  4. Create a zip file to package the index.js and the node_modules directory

    zip -r9 elb-logs-to-elasticsearch.zip *
    

The zip file thus created is the Lambda Deployment Package.

terraform-aws-elb-logs-to-elasticsearch's People

Contributors

fennnec avatar neillturner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.