Image for post
Image for post

This article explains how we can locally test AWS Lambda function written in Ballerina.

Implementing your Lambda function in Ballerina

Lets create a Ballerina file named hello_world.bal. In that create a function with @awslambda:Function annotations that returns “Hello World!” as follows:


Now lets build our Ballerina file using the ballerina build command. I am using Ballerina version 1.1.3 here. You should get an output like this when building with the @awslambda:Function annotation.

$> ballerina build hello_world.bal
Compiling source
Generating executables
@awslambda:Function: sayHello
Run the following commands to deploy each Ballerina AWS Lambda function: aws lambda create-function --function-name <FUNCTION_NAME> --zip-file fileb:// …

Image for post
Image for post
Photo by Thomas Jensen on Unsplash

In this post we’ll be implementing a Web Server using the Ballerina programming language. It is a simple web server which can serve files off a url. It wont have all the gimmicks such as filters, stuff related to security and etc like in Tomcat.

We’ll also build a quick website using “create-react-app” which will then be served by the web server as a website.

Note: We will be using Ballerina 1.1.3 version to implement the web server.

Web Server Implementation

The Ballerina service that we are implementing is an unsecured service(you can secure it later on) that has 2 resource functions. One resource function to serve the files which would directly map to the URL path. …

This post elaborates how you can write and deploy your Ballerina services in an OpenShift cluster effortlessly.

What is Ballerina ? Ballerina is a programming language built for the purpose of implementing integration scenarios which involves microservices, message brokers, databases and etc. With Ballerina, you can write services(http, grpc and etc) with minimum effort and deploy them on the cloud with Ballerina’s cloud native-ness. Visit for more information on the language.

In this post we will be implementing a Ballerina service which returns random quotes from the TV series Game of Thrones . @wsizoo’s game-of-thrones-quotes API is used in generating random quotes which would be the backend of our Ballerina service. Once the Ballerina service is written, annotations from the “ballerinax/kubernetes module are used in generating the artifacts necessary to deploy the service to an OpenShift cluster. I’ll be using Minishift in my local machine to demonstrate this capability of Ballerina. Make note that I am using a nightly build of Ballerina. i.e


Hemika Kodikara

Programmer at WSO2 working on the Ballerina programming language and interested in cloud computing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store