I made two different Lambda functions for this, one for posting and one for reading comments, both access a DynamoDB table containing the comments. When posting comments a POST request is sent to the Lambda endpoint which runs the following Node.js script.
If you took the time to read the full script you probably noticed that it calls both Akismet and reCaptcha, this is to prevent bots and Spam being posted. Additionally it calls PushBullet to send alerts to me whenever someone posts a comment. When storing the comment the referrer (event.headers.Referer) is used to determine which post the comment was made on.
To fetch the comments whenever someone reads a blog post the following script is used.
Its much simpler than the one for posting, it simply reads the blog post URL as a get parameter and fetches any comments from DynamoDB. In addition to these two scripts there is some code on this site which you can view by simply right clicking and then dig through the source code for any relevant parts.
As with all other AWS services you pay for what you use. I am currently on the free usage tier but once that’s finished this setup will cost $0.99 / month for DynamoDB and a couple of cents more for the Lambda service. The cost for Lambda depends on the number of visits, or rather the time the functions run for, the cost for DynamoDB is fixed as the capacity is constantly there and is set by the user (me).
Feel free to test the commenting system out below and if you have any questions you can find my contact details under about.