The Challenge
You want to understand serverless architecture with a simple, testable example. This is the serverless equivalent of 'Hello World' -- quick to deploy, easy to verify, and it introduces the core building blocks you will use in every serverless application.
What You'll Build
- → Lambda function with Python runtime
- → API Gateway HTTP API endpoint
- → Public HTTPS URL to test the function
- → IAM role and permissions configured
- → Complete serverless architecture in minutes
Try This Prompt in Pulumi Neo
Run this prompt in Neo to deploy your infrastructure, or edit it to customize.
Best For
Architecture Overview
This deployment creates the smallest useful serverless application: a Lambda function behind an API Gateway HTTP API. Despite its simplicity, it includes every component you need for a production serverless API – the function, the API gateway, the route integration, and the IAM permissions that tie them together.
API Gateway HTTP API receives incoming HTTP requests and routes them to the Lambda function. Compared to the older REST API type, HTTP APIs are simpler, faster, and less expensive, making them the right choice for most new serverless applications. The gateway handles TLS termination, request routing, and throttling, giving you a production-grade API endpoint without configuring any servers.
The Lambda function runs your code on demand. AWS provisions a runtime environment when a request arrives, executes the function, and then freezes or recycles the environment. You pay only for the milliseconds your function runs, which means this deployment costs essentially nothing when idle. The Python runtime keeps the function code readable and easy to modify, making this an ideal starting point for experimentation.
Lambda Function
Executes your application logic in response to API Gateway events. The function receives the HTTP request as a structured event, processes it, and returns a response object with status code, headers, and body.
API Gateway HTTP API
Provides a public HTTPS endpoint that routes requests to the Lambda function. Handles TLS certificates, request validation, and throttling automatically without any infrastructure to manage.
IAM Role
Grants the Lambda function the minimum permissions it needs to execute and write logs to CloudWatch. API Gateway receives permission to invoke the function through a separate resource-based policy.
Common Customizations
- Add request parameters: Modify the function to read query string parameters or path variables and return dynamic responses.
- Connect a database: Add DynamoDB or RDS access to store and retrieve data, turning this into a functional API backend.
- Add authentication: Attach a JWT authorizer to the API Gateway to require authentication on your endpoints.
- Switch to a different runtime: Replace Python with Node.js, Go, or any other Lambda-supported runtime to match your team’s preferences.
Related Prompts
Create a Serverless REST API with Route Hit Counter
You need a serverless API that tracks usage metrics for different routes. This pattern is useful for monitoring API …
Deploy an API Gateway V2 HTTP API with Lambda Backend
You need a modern HTTP API with lower latency and cost than traditional REST APIs. API Gateway V2 HTTP APIs provide a …
Create a Database-Backed API
You need a backend API that can handle CRUD operations without provisioning or managing servers. A serverless approach …
Create a Serverless Video Thumbnail Extractor
You need to automatically process video files when they are uploaded, extracting thumbnails or frames without managing …