Giter Site home page Giter Site logo

epomatti / aws-opensearch-lambda-streaming Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 640 KB

AWS OpenSearch event streaming with Lambda

License: MIT License

HCL 52.50% Python 47.50%
aws aws-elasticsearch aws-lambda aws-opensearch aws-s3 python terraform

aws-opensearch-lambda-streaming's Introduction

AWS OpenSearch

OpenSearch can receive streaming data form a variety of sources:

Create the environment

Create the variables file:

touch .auto.tfvars

Prepare the variables:

region               = "sa-east-1"
master_user_name     = "elasticuser"
master_user_password = "P4ssw0rd#"

Create the infrastructure:

terraform init
terraform apply -auto-approve

Once done the cluster should be available and ready to load sample data.

Stream Data from S3

This example is copied from Loading streaming data from Amazon S3 tutorial.

You'll need to create a Lambda to read objects from S3 and send streaming to OpenSearch.

Start by installing the dependencies:

cd s3-to-opensearch

pip install --target ./package requests
pip install --target ./package requests_aws4auth

Now package the application:

cd package
zip -r ../lambda.zip .

cd ..
zip -g lambda.zip sample.py

Create the Lambda function:

  1. S3 trigger
  2. Choose your bucket
  3. Event type: PUT
  4. Prefix: logs/
  5. Suffix: .log
  6. Acknowledge recursive invocation and add it

Also add the environment variables AWS_REGION and OPENSEARCH_HOST that are used by the Python script.

Finally, you can upload your deployment package:

  1. Choose Upload from and .zip file, then follow the prompts to upload your deployment package.
  2. After the upload finishes, edit the Runtime settings and change the Handler to sample.handler. This setting tells Lambda the file (sample.py) and method (handler) that it should run after a trigger.

Now upload file sample.log to S3 in the logs folder..


Clean-up

Delete the Lambda function.

Run terraform destroy -auto-approve

aws-opensearch-lambda-streaming's People

Contributors

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