Migrating a Service from a Container to Serverless

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

As serverless gains traction, the desire to experiment with moving from containers to serverless is undoubtedly growing. In this hands-on lab, we will review a few of the many things to consider when looking to adapt an application for serverless, specifically AWS Lambda. We will also explore the use of the distro-agnostic Serverless Framework to aid in our refactoring and application deployment.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create an Access Key/Secret Key

Use IAM to create an access key and a secret key for use with the Serverless Framework.

Install Packages

Globally install the serverless package with npm, then install serverless-http to the project.

Refactor the Application

Export the application in app.js and comment out the port assignment line.

Use the Serverless Framework

Use the Serverless Framework to create template handler.js and serverless.yml files, then update these files to reference the application and use serverless-http.

Additional Resources

You are a developer included in an initiative to see if serverless is right for your Node.js applications — specifically, your express apps. Currently, everything is built to deploy via container, and a Dockerfile is included in every app.

To begin testing, you decide to start on the simplest "application" you have: a landing page for a future to-do list app. The testing will require minimal refactoring, enough to demonstrate what may need to be altered in order to migrate the application to serverless. To aid in the refactoring, you opt to use the Serverless Framework to both generate template files and deploy the refactored application to AWS.

Review the application provided in ~/landing-page on the provided Amazon Linux workstation. Install the Serverless Framework using NPM, then refactor the application and update the serverless configurations. Deploy when ready.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?