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”


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