Deploying to AWS Lambda with Serverless Framework

Tadashi Shigeoka ·  Thu, December 13, 2018

I’ll introduce the flow of deploying to AWS Lambda using the Serverless Framework’s aws-nodejs template.

Serverless Framework

Prerequisites

$ node --version
v8.10.0

Assumes you have configured as described in How to register and use multiple AWS accounts with AWS CLI.

From serverless installation to deployment

I’ll go through from serverless installation to deployment referring to the following article:

Install serverless

Install serverless with —global.

npm install serverless --global

Check serverless version

After installation, first check the version.

$ serverless --version
1.35.0

Create service from template

Create a service with the serverless create command by specifying the aws-nodejs template as follows:

serverless create --template aws-nodejs

Deploy to AWS Lambda

Deploy to AWS Lambda with the serverless deploy command.

$ serverless deploy --aws-profile 2nd-account
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (17.56 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...............
Serverless: Stack update finished...
Service Information
service: aws-nodejs
stage: dev
region: us-east-1
stack: aws-nodejs-dev
api keys:
  None
endpoints:
  None
functions:
  hello: aws-nodejs-dev-hello
layers:
  None

That’s all from the Gemba where I tried deploying to AWS Lambda using the Serverless Framework’s aws-nodejs template.

References