Engineering case study
How Coding Panda Runs a Contact Form on a Static AWS Website
By Coding Panda ·
An implementation note on combining S3, CloudFront, Lambda, and SES to handle contact inquiries while keeping the public website statically hosted.
The problem: a static site still needs a backend
This website is exported from Next.js as static HTML and assets, then deployed to Amazon S3 behind CloudFront. That keeps page delivery separate from application execution. A contact form, however, needs server-side validation and email sending; a static S3 origin cannot run a Next.js POST route handler.
The architecture we use
- The visitor submits JSON to
/api/contact/on the website domain. - CloudFront routes that path to a Lambda Function URL while ordinary pages continue to use S3.
- The Lambda validates required fields, formats plain-text and HTML messages, and calls Amazon SES.
- SES sends the inquiry to info@codingpanda.ai. The visitor's address is set as Reply-To.
- The function returns a success or error response for the form to display.
The same distribution also routes the AI chat endpoint to a separate Lambda. Website deployments and backend deployments are separate GitHub Actions workflows.
Authentication belongs on the server
The email function uses a Lambda execution role with permission to call SES. The browser does not receive AWS access keys. Sender, recipient, and region are environment settings; they describe where to send the message, rather than granting access.
CloudFront uses origin access control to sign requests to the function URL. POST requests include the SHA-256 hash of the exact body. The function resource policy grants the distribution both URL invocation and function invocation permissions, with the latter restricted to invocation through the function URL.
Validation and delivery checks
The handler checks required fields and the email format, limits field lengths, escapes content used in HTML, and includes a honeypot field for simple bot submissions. Those measures are a starting point; stronger abuse protection may be needed as traffic grows.
We verified the request-body hash, ran a production build and TypeScript checks, deployed both workflows, and submitted a test through the live form. SES accepted that test. A successful API response means acceptance for sending; it does not by itself prove inbox placement.
When this design fits
This pattern is useful when public pages can be generated ahead of time and only a small set of interactions needs backend code. It avoids moving the entire website to an application server for a contact form.
It also adds responsibilities: monitor delivery failures, manage SES identities and permissions, evaluate rate limits and spam controls, and maintain the CloudFront-to-Lambda routing. Workloads with long-running processes or different latency requirements need their own assessment.