YC
AWS CLOUD & DEVOPS LAB · SERVERLESS COMPUTING

Serverless REST API: AWS Lambda, API Gateway & DynamoDB

An event-driven serverless task management microservice built in AWS ap-south-1 (Mumbai). Evaluates the request lifecycle from HTTP ingress through Amazon API Gateway, proxy invocation into AWS Lambda, and low-latency document storage in Amazon DynamoDB without managing servers or virtual machine runtimes.

Video Demonstration↓
Configured Directly in AWS · No Separate Source Repo
// SOURCE CODE REPOSITORY STATUS

The Lambda, API Gateway, and DynamoDB implementation was configured and demonstrated directly in AWS (ap-south-1). A separate source repository is not currently available.

PROJECT TYPEServerless MicroserviceEvent-Driven Architecture
AWS REGIONap-south-1 (Mumbai)Low Latency Cloud Edge
API INGRESS & PROXYAPI Gateway (task-api)Stage: dev · AWS_PROXY
COMPUTE & STORAGELambda & DynamoDBTable: tasks (UUID PK)
01. CONTEXT & OBJECTIVE

Why Serverless? Moving Beyond Always-On Provisioned Compute

In traditional infrastructure patterns—such as the EC2 instances provisioned in my Expense Tracker lab—virtual machines run 24 hours a day, 7 days a week, consuming compute budget regardless of whether incoming requests arrive. Managing VMs also imposes administrative friction: patching operating systems, handling SSH or SSM daemon connectivity, configuring reverse proxies like Nginx, and managing process managers.

For intermittent workloads, background webhooks, and lightweight CRUD microservices, an event-driven serverless architecture offers an alternative:

  • Zero Idle Compute Costs: Compute execution billing only begins when an HTTP request arrives and terminates immediately after the response payload is returned.
  • No Operating System Maintenance: The underlying runtime container environment, security patches, and hardware scaling are abstracted away by AWS.
  • Elastic Concurrency: Invocations scale horizontally and automatically in response to request volume without pre-provisioning Auto Scaling Groups.

The objective of this project was to establish and verify an end-to-end serverless CRUD flow on AWS: deploying an HTTP API using Amazon API Gateway, proxying calls directly to an AWS Lambda function (gettodo), and storing state in Amazon DynamoDB (tasks table) with real-world verification through Hoppscotch and the AWS Management Console.

02. ARCHITECTURE & REQUEST LIFECYCLE

End-to-End Request Flow: API Gateway to DynamoDB

The architecture follows a classic serverless three-tier pattern in AWS ap-south-1. Every request flows through managed AWS services without a single long-running virtual machine:

// VERIFIED SERVERLESS REQUEST FLOW (AWS ap-south-1)
+-----------------------+
|  HTTP Client          |
|  (Hoppscotch REST)    |
+-----------+-----------+
            |
            | 1. HTTPS POST /dev/tasks  {"title": "...", "status": "..."}
            |    HTTPS GET  /dev/tasks/{id}
            v
+-------------------------------------------------------------+
|  Amazon API Gateway (task-api · ID: sl0g7w7uli)             |
|  Region: ap-south-1 | Stage: dev                            |
|  - CORS Preflight (OPTIONS /tasks, OPTIONS /tasks/{id})     |
|  - Resource Tree: /tasks (GET, POST), /tasks/{id} (GET)     |
|  - AWS_PROXY Integration (Pass-through event mapping)       |
+-----------------------------+-------------------------------+
                              |
                              | 2. Lambda Proxy Event
                              |    (body, pathParameters, headers)
                              v
+-------------------------------------------------------------+
|  AWS Lambda Function (gettodo)                              |
|  - Parses event JSON payload                                |
|  - Generates UUID v4 identifier for new tasks               |
|  - Executes PutItem / GetItem operations via AWS SDK        |
|  - Formats structured HTTP response (200 / 201)             |
+-----------------------------+-------------------------------+
                              |
                              | 3. DynamoDB SDK Read / Write
                              v
+-------------------------------------------------------------+
|  Amazon DynamoDB (Table: tasks)                             |
|  - Partition Key: id (String UUID)                          |
|  - Attributes: title (String), status (String)              |
|  - Consumed RCUs: 2 RCUs per item scan                      |
+-------------------------------------------------------------+

The Lambda Proxy Integration Lifecycle

When a request reaches task-api, API Gateway uses AWS Lambda Proxy Integration (AWS_PROXY). Instead of requiring complex Apache Velocity (VTL) mapping templates in the API Gateway stage, the raw request—including HTTP headers, path parameters (e.g. {id}), query parameters, and raw JSON body—is packaged as a JSON event dictionary and passed directly to the function handler.

The Lambda handler inspects the event:

  • On POST /tasks: Reads the JSON request body, generates a UUID string identifier (e.g. ba75fed5-9f42-4aa9-9f8a-165ab10d3600), writes the item to the tasks DynamoDB table, and returns HTTP status 201 Created.
  • On GET /tasks/{id}: Extracts id from event["pathParameters"], queries the tasks table for the matching partition key, and returns the stored document with HTTP status 200 OK.
03. TECHNICAL IMPLEMENTATION & VERIFIED ENDPOINTS

Verified Endpoints, Schemas & AWS Resources

All resource names, identifiers, and payload structures below correspond strictly to the actual AWS environment captured in the screen recording:

HTTP METHODRESOURCE PATHINTEGRATION TARGETBEHAVIOR & RESPONSE
POST/dev/tasksAWS_PROXY → Lambda gettodoCreates new task item in DynamoDB; returns 201 Created with generated UUID
GET/dev/tasks/{id}AWS_PROXY → Lambda gettodoQueries DynamoDB by partition key; returns 200 OK with task record
GET/dev/tasksAWS_PROXY → Lambda gettodoLists task items from DynamoDB table
OPTIONS/tasks, /tasks/{id}MOCK (CORS Headers)Preflight CORS handshake allowing Content-Type and Authorization headers
// VERIFIED POST REQUEST 01

POST /dev/tasks · Response: 201 Created (292 ms)

// Request Body:
{
  "title": "Learn AWS Lambda",
  "status": "pending"
}

// Response Body (201 Created):
{
  "id": "ba75fed5-9f42-4aa9-9f8a-165ab10d3600",
  "title": "Learn AWS Lambda",
  "status": "pending"
}
// VERIFIED POST REQUEST 02

POST /dev/tasks · Response: 201 Created (115 ms)

// Request Body:
{
  "title": "Learn AWS TF",
  "status": "done"
}

// Response Body (201 Created):
{
  "id": "2a54cc82-1faf-44d9-bacd-5ea316704f01",
  "title": "Learn AWS TF",
  "status": "done"
}
04. RECORDING EVIDENCE & DEMONSTRATION

Authentic Screen Recording: Live End-to-End Verification

The video below demonstrates the full serverless flow in real time across the AWS Management Console and Hoppscotch API client:

0:00 / 0:00
Near-Viewport Autoplay

Authentic recording: DynamoDB table scan (initial 0 items), Hoppscotch POST requests with 201 Created responses, subsequent DynamoDB scan showing populated items, GET query retrieval, and API Gateway method execution console.

RECORDING BREAKDOWN BY TIMESTAMP:
  • 00:00 – 00:08 (DynamoDB Initial State): Displays the Amazon DynamoDB console in region ap-south-1. An item scan on table tasks returns 0 items. Then a manual scan shows 1 item as the initial record is created.
  • 00:08 – 00:23 (Hoppscotch POST Execution): Switches to the Hoppscotch REST client. Sends a POST request to https://sl0g7w7uli.execute-api.ap-south-1.amazonaws.com/dev/tasks with JSON payload. Returns 201 Created in 292ms with UUID ba75fed5.... A second POST for "Learn AWS TF" succeeds in 115ms with UUID 2a54cc82....
  • 00:23 – 00:32 (GET Query by Identifier): Sends an HTTP GET request to the path-parameter endpoint retrieving the stored task record. Returns 200 OK in 98ms with the full task object.
  • 00:32 – 00:40 (API Gateway Console Verification): Navigates to Amazon API Gateway console for task-api (sl0g7w7uli). Inspects the resource tree (/tasks and /tasks/{id}), method execution flow, and Lambda Proxy Integration settings pointing to function gettodo.
05. CHALLENGES & ENGINEERING DECISIONS

Key Architectural Decisions & Observations

1. Lambda Proxy Integration vs. Non-Proxy (VTL) Mapping

API Gateway allows two primary integration patterns: Non-Proxy integrations with Velocity Template Language (VTL) mappings, and Lambda Proxy Integration (AWS_PROXY). Non-proxy integrations force request validation and JSON transformation into API Gateway configuration, which is tedious to maintain and difficult to unit test. Selecting Lambda Proxy Integration shifts transformation logic into the handler code, where standard language features, schema validation, and logging libraries can operate freely.

2. Cold Start Latency vs. Warm Re-Use

The recording reveals real-world serverless execution characteristics: the first POST request took 292ms, whereas the second POST completed in 115ms and the subsequent GET in 98ms. The initial ~180ms delta illustrates container initialization (cold start), while subsequent requests leverage the warm execution environment and re-used DynamoDB client connections.

3. DynamoDB Key Design & RCUs

Using a v4 UUID as the partition key (id) guarantees uniform distribution across DynamoDB physical partitions, preventing hot-partition bottlenecks under write spikes. The console scan report shows 2 Read Capacity Units (RCUs) consumed per scan, highlighting why point-in-time item lookups (GetItem via partition key) should always be favored over full table scans in production workloads.

06. IMPLEMENTATION STATUS & BOUNDARIES

Implementation Status & Honest Technical Boundaries

IMPLEMENTATION STATUS MATRIX
  • Verified & Implemented: Amazon API Gateway REST API (task-api), deployed to stage dev in ap-south-1; Lambda proxy integration with buffered response transfer; AWS Lambda function gettodo; Amazon DynamoDB table tasks with partition key id; CORS OPTIONS methods; live POST and GET request cycles verified through Hoppscotch and AWS console.
  • Source Code & Repository Boundary: The Lambda, API Gateway, and DynamoDB implementation was configured and demonstrated directly in AWS (ap-south-1). A separate source repository is not currently available.
  • Security & Domain Boundaries: Authentication authorizers (such as Amazon Cognito User Pools or Lambda authorizers) were not attached to the dev stage endpoints; no custom Route 53 domain name was mapped.
07. KEY TAKEAWAYS & NEXT STEPS

What Building This Taught Me & Future Improvements

PRACTICAL NEXT STEPS FOR PRODUCTION HARDENING:
  • Infrastructure as Code (IaC): Codify the entire serverless stack into AWS SAM (Serverless Application Model) or Terraform configurations to guarantee repeatable, version-controlled deployments.
  • API Authentication: Add an Amazon Cognito User Pool Authorizer or JWT validator to restrict API access to authenticated users.
  • Observability & Distributed Tracing: Enable AWS X-Ray active tracing on API Gateway and Lambda to trace end-to-end downstream latency bottlenecks into DynamoDB.
  • Custom Domain & SSL: Provision an ACM certificate and map an API Gateway custom domain (e.g. api.yamandeep.in) with CloudFront edge caching.