Context
A reference build for clients who need a real backend API — not just a static site — but don't want to own EC2 instances, patch a fleet, or pay for idle compute.
Problem
A small API workload (a contact form handler, a webhook receiver, a lightweight backend) doesn't need a always-on server. Running one anyway means paying for idle capacity and owning OS patching, scaling policy, and uptime for infrastructure that's busy a tiny fraction of the time.
Approach
API Gateway as the HTTP front door, Lambda for the compute (pay only per invocation), and DynamoDB where persistence is needed — all defined in OpenTofu. IAM roles are scoped per-function to exactly the resources that function touches, not a shared broad role. Deploys run through the same GitHub Actions + OIDC pattern as the static-hosting build, so both projects share one deploy story.
Outcome
Zero cost at rest, automatic scaling with traffic, and no servers to patch or right-size. For spiky or low-volume workloads this comes out cheaper than the smallest always-on instance, while removing an entire category of ops work (OS patching, capacity planning) from the picture.
Architecture
API Gateway handles routing, request validation, and throttling at the edge. Each route maps to a purpose-built Lambda function rather than one monolithic handler, so IAM permissions and cold-start footprint stay scoped to what that specific route actually needs. DynamoDB is used where state needs to persist, with access patterns designed around its key structure up front rather than retrofitted later.
Why serverless here
For workloads that are bursty or genuinely low-volume, the always-on cost of even a small EC2 instance is hard to justify next to Lambda’s per-invocation pricing — and it removes OS patching, capacity planning, and instance-fleet management from the maintenance list entirely.
Cost
Effectively $0 at rest; cost scales linearly with actual invocations. For a low-traffic API, this typically lands well under $5/month.
← All projects