https://github.com/chrismwilliams/static-form-lambda
Serverless template, creating a FaaS aws lambda to handle form submissions
https://github.com/chrismwilliams/static-form-lambda
amazon-web-services contact-form email faas lambda-functions nodejs sendgrid serverless static-site
Last synced: 8 months ago
JSON representation
Serverless template, creating a FaaS aws lambda to handle form submissions
- Host: GitHub
- URL: https://github.com/chrismwilliams/static-form-lambda
- Owner: chrismwilliams
- License: mit
- Archived: true
- Created: 2018-06-19T08:29:34.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2022-08-03T12:57:15.000Z (over 3 years ago)
- Last Synced: 2025-03-22T09:46:37.352Z (about 1 year ago)
- Topics: amazon-web-services, contact-form, email, faas, lambda-functions, nodejs, sendgrid, serverless, static-site
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AWS Lambda For A Static Contact Form 📬
A simple AWS Lambda serverless template creating an api to post your form data to, which can then be emailed to your preferred address. Ideal for a contact form on a static website
## Uses: Amazon Web Service, Serverless & SendGrid
## Requirements:
- An [AWS](https://aws.amazon.com/) Account
- Install serverless cli: `npm install -g serverless`
- Add your AWS credentials to [serverless](https://serverless.com/framework/docs/providers/aws/guide/credentials/)
- A [SendGrid](https://sendgrid.com/) Account
- An api [key](https://app.sendgrid.com/settings/api_keys), (_keep this handy as by default you have to add it to AWS after deploying_)
- (Optional) A configured template and resulting template ID to template your emails
- Download this repository
- Install dependencies: `yarn install` / `npm install`
- Rename sample.env to .env and add your SendGrid API key
- (Optional) Update the serverless.yml region to your preference, defaults to London.
- Open up handler.js and update the mailOptions object to your preference
- After deploying via the serverless command, add your SendGrid API_KEY to the lambda environment
## Terminal Commands:
```bash
$ serverless deploy -v
# This pushes the whole thing to AWS, creating your personal endpoint to post your form data to
# You can now view the lambda (aws > Lambda > Functions) and add your SendGrid API_KEY to the environment
$ serverless deploy function -f contact
# Made changes to just the handler.js file?
# Instead of deploying the whole thing again which can take a while, this just updates the Lambda.
$ serverless offline start
# This command will spin up a local server that allows you to test your function locally.
```
## Form Example
```html
Name
Please don't fill this in
Email
Your Message
```