Serverless Framework SES and DynamoDB Contact Form

faizanbashir faizanbashir Last update: Jun 22, 2022

Python SES DynamoDB Contact Form

serverlesslicense

AWS SES DYNAMODB tutorial using Serverless Framework written in Python

Application Architecture

Serverless Application Architecture

Serverless Framework Setup

CommandDescription
npm install -g serverlessInstall Serverless CLI
npm installInstall Serverless dependencies
npm install serverless-domain-manager --save-devInstall plugin to use custom domains
Set up an AWS account with admin permissionsDocumentation

How to Deploy

$ git clone https://github.com/faizanbashir/python-ses-dynamodb-contactform.git$ cd python-ses-dynamodb-contactform$ npm install$ sls deploy -v

Creating Route53 records for custom domain

$ sls create_domain

Service Endpoints

The service exposes 2 REST API endpoints:

EndpointDescriptionParameters
POST /sendMailSubmit the data from contact form{"firstname": "John Doe", "email": "[email protected]", "message": "Hi there"}
GET /listRetrieves all the contact form submissions-

Invocation

curl --header "Content-Type: application/json" \    --request POST \    --data '{"fullname": "John Doe", "email": "[email protected]", "message": "Hi there"}'\    <host>/sendMail -H 'x-api-key: <API_KEY>'curl <host>/list -H 'x-api-key: <API_KEY>'

sls or serverless CLI Usage

deploy function command

Deploy only one function:

sls deploy function -f <function-name> -v

invoke command

Run a specific function with a provided input and get the logs

sls invoke -f <function-name> -p event.json -l

Run a specific function without input and get the logs

sls invoke -f <function-name> -l

logs command

Tail the logs of a function:

sls logs -f <function-name> -t

info command

Information about the service (stage, region, endpoints, functions):

sls info

help command

Just use it on anything:

sls  help

or

sls <command> --help

Subscribe to our newsletter