Skip to main content

GitHub Repository

You can find the project source code on GitHub.
This tutorial implements a serverless application and deploys it to AWS Lambda using Serverless Framework

Prerequisites

  1. Install the Serverless Framework with npm i serverless -g

Project Setup

Create a Serverless Framework application with the following options:
Create package.json with @upstash/redis as a dependency:
package.json
Install the dependencies:

Database Setup

Create a Redis database using Upstash Console or Upstash CLI and copy the UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN into your .env file.
.env

Counter Function Setup

Update handler.js:
handler.js
Update serverless.yml to pass the environment variables:
serverless.yml

Developing

Run the following command to start your dev session.

Deployment

Run the following command to deploy your service.
Visit the output url.