querying rds instance with aws lambda using nodejs

Querying RDS MySQL DB with NodeJS Lambda Function

Hi all, recently I tried AWS lambda for the first time and my task was to query an RDS MySQL database. In this blog post I will share my experience on that.

First Attempt – Using the Inline Code Editor

Since I was using NodeJS, the first thing was to figure out a good MySQL node package and I found this mysql library thanks to Douglas Wilson and it has a good documentation as well. Writing the code was simple.

var mysql = require('mysql');
var connection = mysql.createConnection({
    host: "<rds_endpoint>",
    user: "<rds_username>",
    password: "<password>",
    database: "<db_name>",
// console.log(connection);
exports.handler = (event, context, callback) => {
    connection.query('show tables', function (error, results, fields) {
        if (error) {
            throw error;
        } else {
            // connected!
            callback(error, results);
            connection.end(function (err) { callback(err, results);});

Continue reading “Querying RDS MySQL DB with NodeJS Lambda Function”


Running a custom startup script in CentOS / RHEL 7

Hi All,

During my work at Adroitlogic, in one of my tasks I had to start & configure a set of EC2 machines which included our B2B AS2 integration solution AS2Station. This was a recurring task and yes you guessed right it was boring. The configuration steps in summary were follows.

  • Extracting the private IP of eth0 interface
  • Adding few iptable rules with the extracted private IP
  • Mounting a ramdisk (which is used by the UltraESB filecache)
  • Starting Apache Zookeeper service (which is the leadership election and coordination service used by UltraESB)
  • Starting UltraESB service
  • Starting AppServer service (which is AS2Station front-end)

My good friend Janaka, suggested me that I should try to use an startup script to get this done. Turns out it was pretty easy. Let me share the steps with you all as it might be useful to some of you as well.

Continue reading “Running a custom startup script in CentOS / RHEL 7”

as2 protocol for b2b integration

AS2 Protocol for Business Data Interchange via HTTP, Part 2

The main idea of the AS2 protocol defined in the RFC 4130 is on how we can exchange structured business data securely using the HTTP transfer protocol. In part one of the AS2 article series, we looked at an overview of the AS2 (Applicability Statement 2) protocol and why it wins over the other B2B protocols. We, the developers of the B2B integration platform AS2Gateway, have been working with AS2 protocol for quite some time now and today in this article we hope to give away some insight on how an AS2 message is composed using S/MIME format with a few lines of Java code.

Without further ado, let’s jump right in. The basic structure of an AS2 message consists of a MIME format inside an HTTP message with a few additional specific AS2 headers. The final structure of the composed AS2 message will be as follows. In this article, we’ll go in a step-by-step manner to create the final encrypted HTTP body starting from a document.

as2 protocol for b2b integration

Continue reading “AS2 Protocol for Business Data Interchange via HTTP, Part 2”

Serverless Architecture on AWS

Cloud Computing is gradually taking over the world and it is becoming a technology that the industry can’t live without. This comes as no surprise as with the business drivers such as capacity planning, cost reduction and organizational agility, Cloud Computing has become the most preferred choice for most organizations. One of the main concepts of Cloud Computing is that the technology is abstracted away from the user, which basically means that the users does not have to worry about how the cloud service is provided and they can simply focus on using the cloud services. Having this concept in mind cloud providers try to provide everything as a service and so far the main delivery models are Infrastructure as a Service (IaaS), Platform as a Service (PaaS) and Software as a Service (SaaS).

It is the advancement of technologies such as broadband networks and internet architecture, data center technologies, virtualization, web technologies, multitenant technologies and service technologies which made way for Cloud Computing and with new changes and technologies coming in new Cloud Computing trends and delivery models are emerging as well. One of those trending cloud delivery models is Function as a Service (FaaS) which is also known as Serverless Architecture.

Here I would like to share a presentation and a report that I did on Serverless Architecture for one of my MSc course modules.

Cheers! 🙂

~ Rajind Ruparathna