When I switched this site from Django to Pelican in January last year, I chose Parse to handle my contact form, and Mandrill to send the email. Within a couple of months, Facebook had announced that they were closing Parse, and Mailchimp decided to stop the free tier for Mandrill. So much for static sites being easier to maintain!
This week, I've updated the contact form to use AWS. The new form works as follows.
- The API gateway calls my Python lambda function
- The lambda function uses boto3 to send the message to me using SES
Setting up the components through the web interface and connecting them together would be time consuming, so there a number of frameworks that aim to simplify the process. I tried out Serverless and Gordon, before finally settling on Chalice.
Next I looked at Gordon, which appealed because it's written in Python and has lots of examples. The biggest problem was that I couldn't get CORS working. There is an open pull request for this, but at the time of writing, the last commit was three months ago, so I don't know when it might be merged.
Finally, I tried Chalice. It's written in Python, and all the configuration was done by decorating my function, rather than yaml config. CORS support was as easy as using cors=True in the decorator. It has a neat experimental feature which introspects the lambda function and generates an IAM policy with the correct permissions (in this case sending the email with SES).