A production-ready serverless contact form built using AWS services. This project enables a secure, scalable, and cost-efficient solution for collecting and emailing form submissions—no traditional server required.
- ⚙️ Serverless Backend – Powered by AWS Lambda, API Gateway, and SES.
- 📥 Email Notifications – Automatically sends an email on each form submission.
- 🧾 Infrastructure-as-Code – Fully defined in a CloudFormation template.
- 🌐 Static Frontend Hosting – Upload HTML/CSS/JS to an S3 bucket.
- 🔒 Environment Variables – Sender/receiver email configured via Lambda env vars.
- 🚫 Zero Maintenance – No EC2, no backend server costs.
Layer | Technology |
---|---|
Frontend | HTML, CSS, JS (S3-hosted) |
Backend | AWS Lambda (Node.js 18.x) |
AWS SES (Simple Email Service) | |
API | AWS API Gateway |
IaC | AWS CloudFormation |
. ├── backend/ │ └── cloudformation/ │ └── template.yml # Infrastructure template │ └── index.js # Lambda function ├── frontend/ │ └── index.html # Contact form UI │ └── styles.css # Optional: styling │ └── script.js # Optional: JS to call API └── README.md
aws cloudformation package \
--template-file backend/cloudformation/template.yml \
--s3-bucket YOUR_DEPLOYMENT_BUCKET \
--output-template-file backend/cloudformation/packaged.yml
### 2. Deploy the Stack
```bash
aws cloudformation deploy \
--template-file backend/cloudformation/packaged.yml \
--stack-name ContactFormProduction \
--capabilities CAPABILITY_IAM
### 3. Upload Frontend to S3 (Optional)
```bash
aws s3 sync frontend/ s3://YOUR_FRONTEND_BUCKET/
###
🧪 Testing the Contact Form
You can test your deployed form by:
Navigating to your S3 bucket’s public URL (if configured).
Filling out the form and submitting.
Verifying that an email arrives at your configured recipient address.
---
#When You Might Need CORS Changes:
If you move to production, you might want to tighten security:
// Instead of "*", specify your actual domain
"Access-Control-Allow-Origin": "https://yourdomain.com"
---
## ✅ Use Cases
This serverless contact form is ideal for:
# 🏠 Personal Portfolio Sites
Collect contact requests without relying on third-party form providers.
# 🧑💼 Freelancers & Consultants
Automatically forward client inquiries from your landing page to your email.
# 🏢 Small Businesses
Integrate into your site without maintaining any backend infrastructure.
# 📄 Static Sites (e.g., GitHub Pages, Netlify)
Easily plug in this API endpoint to capture leads or feedback from visitors.
# 🛡️ Security Tips
Ensure your SES domain/email is verified.
Use AWS WAF or API Gateway throttling for rate limiting.
Consider using CAPTCHA or a honeypot field to prevent spam.
#📘 Environment Variables
Make sure to define the following in your Lambda environment:
Variable Description
SENDER_EMAIL Verified SES email to send from
RECIPIENT_EMAIL Email to receive form submissions
# 🧰 Requirements
AWS CLI configured (aws configure)
An S3 bucket for deployment assets
AWS SES email/domain verification
Node.js 18.x compatible Lambda function
# 🤝 License
This project is open-source and available under the MIT License.
#💡 Inspired by
This project was inspired by the need for simple, reliable contact forms that don’t rely on external services or paid APIs—ideal for privacy-conscious or budget-focused deployments.