Design a site like this with
Get started

[4] [ProjectX] – From Zero to Hero in Serverless

Let’s begin our journey of learning Serverless computing. I am going to be using ProjectX as the moniker for it. So, whenever you see this word in title of blogpost, you will know this post is one in the series of posts helping you to start from Zero and become a Hero in the Serverless world

We will be focusing primarily on learning AWS Lambda. But as we move along, we will also learn about utilizing other AWS services to fulfill additional requirements in the realm of serverless computing.

Why Serverless

In my opinion, Serverless computing is a natural evolution of the rapid progress we are making in Cloud computing. You can refer to my first blog [1] Serverless – more FinDev than DevOps by Yan Cui for more details.

Whether you think Serverless is going to be a big hit or a big miss, it will remain as one of the options for hosting your code in cloud. So, it is better to learn it to cover all bases of our knowledge in cloud.

Serverless & Microservices

One of the best implementations of Serverless computing is with Microservices-based architectures. So, lets aim to implement ProjectX as a bunch of Microservices.

Technology Choice

Out of the box, AWS Lambda supports the following technologies natively

  1. .Net Core
  2. Java
  3. Node.js
  4. Go
  5. Python
  6. Ruby

Additionally, there is an option called Custom Runtime, which basically allows BYOT (i.e. Bring Your Own Technology). Using this option, you can host COBOL code in Lambda functions if you wanted.

So, the takeaway from this is, you are not confined to build on a single technology stack. You can choose a mix of many technologies to construct different Microservices as you please.

In our case, let’s start with the combination of Node.js/JavaScript. Occasionally, we might dabble in other technologies as required.

Why Node.js/JavaScript

Node.js provides us with an event-driven server-side JavaScript environment. The programming language used is JavaScript. This has the benefit of using the same language (i.e. JavaScript) on both client-side and server-side which reduces complexity of multi-languages coding as well as assembling team of different types of developers. Node.js offers us a light weight high-performing environment for server-side execution that compiles and executes JavaScript at lightning fast speeds.

JavaScript has become the language of choice for building Microservices since it is very lean at its core and allows you to add dependencies as per the requirements. This is in sharp contrast with so-called established enterprise languages like Java and C-Sharp (C#). These languages contain classes and constructs that cater to all kinds of requirements and hence become large and bloated in size and take more time to build and deploy its binaries

Also, Node.JS environment has native support for RESTful APIs and its module-based system helps in organizing code as independent micro-units which work well in isolation as well as can work together just as easily.

The other benefit of Node.js ecosystem is the choice you get of various specialized libraries and packages that are created for specific purposes. For example, to create API, you can use Hapi.js or any other packages you like. For implementing Promises, you can use standard “promises” package or various flavors of it. Hence you are not restricted to doing things in one single way and can make use of the best packages for your unique programming needs.

Because of such agility, the combination of Node.JS and JavaScript has become the most favored choice of technology stack for developing Microservices.

Sample Use case

So even though we will be embracing the Microservice architecture, we will require a sample use case for implementation. What will that be?

Jeff Bezos build the whole Amazon empire by selling books. So why not start with the same and who knows we may also get lucky.

So, our use case for building Serverless Microservices will be to start with a books catalog. We will extend it as per our needs later.

One final step before we start banging our keyboards to produce code, is to correctly setup the AWS configuration with Cloud9 IDE. So please follow the instructions below and complete the setup.

1: Setting up AWS account and permissions properly

It is AWS best-practice to Not work with root accounts. So, create an additional user called Administrator, give him AdministratorAccess permissions and enable Multi-factor authentication for this user.

You can start using this user for our project.

After the Administrator user is created successfully with right permissions, make sure to grab the following two details for this user

  1. Access key ID (e.g. AKI**********Z6Y)
  2. Secret access key (e.g. aKRaswe*****************5bhMWn)

2. Configure Cloud9 to use Administrator user

Click on AWS Cloud9 on top left of your screen then click Preferences and in the window that opens, scroll down to AWS Settings

 Disable the option AWS managed temporary credentials, as shown below

Then right-click on C9.NodeJS folder, select Open Terminal Here option from Menu.

Type aws configure here

Enter the appropriate details as shown above and the setup is done.

With that you are all set to begin development in Serverless world. So, Operation ProjectX commences from next blog post.

Stay tuned and Happy Clouding!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: