Skip to main content

Amazon Web Services

Monolith to Serverless in 10 Minutes

Istock 1069272512

The web-based Application Programming Interface (API) concept has been around since the ’90s. Due to the need to maintain and grow business, there are now centuries worth of existing code, most of which we define today as monolithic. The thought of change for many companies is daunting at best, if not inconceivable.

There are countless theories, concepts, and architectures to help determine the best way to break apart the monoliths. But then what? Once you have established an AWS account, how do you get your serverless microservices into AWS?

There is a well-proven tool called Claudia.js to the rescue. Claudia.js is an open-source deployment tool for microservices to get you started and maintain your Lambda functions and Amazon API Gateway.

Claudia.js automates packaging the NPM dependencies, ensuring the API is deployable, condensing the package for transport, configuring the API gateway, then installing the AWS Lambda function. Claudia.js sets everything up in a manner a JavaScript developer expects out of the box

 

Hello World

Let’s create our Hello World example “Monolithic” service.

  1. Create a new folder and initialize with NPM or Yarn
    • npm init

  2. Create an app.js file with the following:
    • var apiBuilder = require(‘claudia-api-builder’), api = new ApiBuilder();

      module.exports = api;

      api.get(‘/helloworld’, function () {

      return ‘hello world’;

      });

  1. Add the Claudia API Builder to the package.json
    • npm install Claudia-api-builder –save

  2. As a final step, install Claudia.js globally.
    • npm install -g Claudia

  3. Finally, install your Hello World microservice in AWS:
    • claudia create –region uss-east-1 –api-module app

Amazon Web Services - Avoid Contact Center Outages: Plan Your Upgrade to Amazon Connect
Avoid Contact Center Outages: Plan Your Upgrade to Amazon Connect

Learn the six most common pitfalls when upgrading your contact center, and how Amazon Connect can help you avoid them.

Get the Guide

Within a few minutes, you should receive a response similar to the following:

{

“lambda”: {

“role”: “test-executor”,

“name”: “test”,

“region”: “us-east-1”

},

“api”: {

“id” : “4l9jdd7gy9k”,

“module”: “app”,

“url”: “https://4l9jdd7gy9k.execute-api.us-east-1.amazonaws.com/latest”

}

}

 

When Claudia.js completes, he results will give you the root URL of the new API Gateway resource. Claudia created an endpoint resource for /HelloWorld. At this point, you can add /HelloWorld to the URL above and try out the new endpoint in a browser or console. You should see the ‘Hello world’ response.

In less than 10 minutes, you have deployed your first Lambda function and API Gateway endpoint in AWS

But what just occurred?:

Here is what Claudia.js just did:

  • Created a copy of the project
  • Packaged all the NPM dependencies
  • Tested that the API is deployable
  • Zipped up your application and deployed it to Lambda
  • Created the correct IAM access privileges
  • Configured an API gateway endpoint with the /HelloWorld resource
  • Linked the new resource to the previously deployed Lambda function
  • Installed the API Gateway transformation templates

The last step for Claudia is to save the configuration to a local file called claudia.json so that you can update the function without having to remember the details. Claudia.js makes it just as easy to update and maintain your new microservices.

Conclusion

The most critical hindrance for companies to move from their exisiting monolithic backend to a more modern, agile framework is how to get your hard work of converting services to a microservice deployed into AWS. In addition to adding Claudia.js for converting from monolithic services to microservices, Claudia.js can be added to your exisiting continuous integration and deployment processes to reduce your time to market and increase quality.

How Can Perficient Help You?

Perficient is a certified Amazon Web Services partner with more than 10 years of experience delivering enterprise-level applications and expertise in cloud platform solutions, contact center, application modernization, migrations, data analytics, mobile, developer and management tools, IoT, serverless, security, and more. Paired with our industry-leading strategy and team, Perficient is equipped to help enterprises tackle the toughest challenges and get the most out of their implementations and integrations.

Learn more about our AWS practice and get in touch with our team here!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Rob Morris

Rob Morris is a Cloud Engineer for Perficient. Writing code since the mid-80, Rob has spent much of his last 15 years assisting others with the adoption of cloud technologies. He graduated with honors from Southern New Hampshire University with a degree in Business Administration.

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram