Coder Social home page Coder Social logo

ballerina-lambda's Introduction

Build Status

Running a Ballerina Service as a Serverless function in AWS Lambda

This project implements an AWS Request Handler, which is triggered by AWS Lambda when there is an event. The request handler invokes the Ballerina Service resource and returns the response.

The Ballerina service is compiled using an unofficial API in the constructor. The handler method locates the service resource in the compiled Ballerina service and executes it programmatically.

For more information, see Ballerina Services in Serverless World

How to run your own Ballerina service in AWS Lambda

Clone the ballerina-lambda repository.

git clone https://github.com/chrishantha/ballerina-lambda --depth=1
cd ballerina-lambda/

Save ballerina service in ballerina-services directory. Currently, the ballerina-lambda expects a ballerina package name, which includes the Ballerina service. Therefore, you need to make sure that the ballerina service is in a package. There is already a sample helloWorldService inside the ballerina-services directory.

Now build the maven project.

mvn clean package

There should be a zip file inside the target directory.

Use the zip file as the package for AWS Lambda function.

Following must be specified as the handler method.

com.github.chrishantha.lambda.ballerina.BallerinaRequestHandler::handleRequest

You need to configure following environment variables.

Environment Variable Description Default
BAL_PACKAGE The name of the Ballerina package, which includes the Ballerina Service. echoService
BAL_SERVICE_PATH The full path for the Ballerina service resource. /echo/
BAL_SERVICE_METHOD The HTTP Method used by the Ballerina service resource POST

License

Licensed under the Apache License, Version 2.0

ballerina-lambda's People

Contributors

chrishantha avatar

Stargazers

 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.