mediumFull Stack EngineerStartup
AWS S3, CloudFront, and Lambda — how do they work together for serverless?
Posted 18/04/2026
by Mehedy Hasan Ador
Question Details
"Host Next.js static export + API on AWS without managing servers."
Suggested Solution
Stack
S3 (static files) → CloudFront (CDN) → Users, Lambda (API) → API Gateway → CloudFront// Lambda handler
export const handler = async (event) => {
const apps = await prisma.application.findMany();
return { statusCode: 200, body: JSON.stringify(apps) };
};
// Pay per invocation (~$0.20/1M requests), cold start ~200ms
Best for variable traffic. Not for constant heavy traffic or long-running processes.