CDK01-Learn CDK while Building a Serverless Application using Lambda, API Gateway and DynamoDB in Minutes

Amit Rai
14 min readOct 2, 2024

Learn the basics of AWS CDK by building a serverless app step-by-step

Create by Owner

In this article, we’ll take a hands-on approach to learning AWS CDK by building a scalable serverless application. We’ll be creating a Journal app, where users can create, edit, view, list, and delete their entries.

What makes this interesting? we’ll code the application logic in NodeJS while deploying the entire infrastructure using AWS CDK in Python

The requirements for the Journal app are straightforward: users should be able to create, edit, retrieve, and delete journal entries.

Let’s break down these features into individual components and map them to AWS services:

1. Business Logic:

AWS Lambda will handle the logic for creating, editing, retrieving, listing, and deleting journals. We’ll write the business logic in NodeJS and for each action, we need a separate Lambda function.

  • Journal Create Lambda :
import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb";

const region = process.env.AWS_REGION;
const client = new DynamoDBClient({ region });

export const handler = async (event, context) => {…

--

--

Amit Rai

AWS Architect | AWS DevOps | Developer | Generative AI | Enthusiastic Writer | www.linkedin.com/in/amitraikkr