Create a Serverless REST API with Route Hit Counter

By Pulumi Team
Published
Updated

The Challenge

You need a serverless API that tracks usage metrics for different routes. This is useful for monitoring API usage, understanding which endpoints are most popular, or building analytics dashboards.

What You'll Build

  • API Gateway REST API with greedy path parameter
  • Lambda function with proper IAM permissions
  • DynamoDB table for storing route visit counts
  • Automatic counter incrementing on each request
  • JSON response with route name and current count

Neo Try This Prompt in Pulumi Neo

Edit the prompt below and run it directly in Neo to deploy your infrastructure.

Best For

Use this prompt when you need to track API usage patterns, build analytics for your endpoints, or create a simple monitoring solution. Great for microservices, serverless applications, or when you want to understand how your API is being used.

Architecture Overview

This prompt creates a complete serverless architecture:

  • API Gateway - Entry point for HTTP requests
  • Lambda - Serverless compute to handle requests
  • DynamoDB - NoSQL database for fast counter increments
  • IAM Roles - Secure permissions for Lambda to access DynamoDB

The system automatically tracks every route access and maintains counters in DynamoDB.