Mostly I’ve been working with EC2 instances, but today I want to explore working in the serverless area with Lambda functions. I am hoping to work with data from a DB for data analysis.
I’m going to be working through this as part of a tutorial, so I’m going to be including those resources – these blog posts are helpful for me for reference too. Note that I originally wrote this back in February as I was working my way through the AWS re/Start program- I’ll be diving into this in a much more complete manner in the near future (November 2025).
Goal: deploy and configure an AWS Lambda based serverless computing solution, the function of which will generate a sales analysis report by pulling data from a database and then emailing the results on a regular basis. The database secrets (username, password, etc) are stored in the Parameter Store of AWS Systems Manager, while the DB is part of an EC2 LAMP instance. Details Involved will include:
- IAM Role for creating an analysis report
- Lambda function to create analysis report
- Lambda function to extract the data from MariaDB
- Lambda function to create the analysis report
- SNS topic created and email sent
- **Infrastructure-wise**: EC2 with attached security group within VPC.

A CloudWatch event > Lambda function invoked at x time daily

The DataExtractor function runs an analytical query against the DB, using PyMySQL Python library to access MySQL DB. The returned values are provided to salesAnalysisReport function, which formats the data into a message- emailed to clients subscribed to the topic.
Here’s an extra challenge that I hope to work on – that will be another day though

Back to business, here’s the workflow of what needs to happen:

There are two roles, the first is salesAnalysisReportRole. That has four permissions policies attached to it: AmazonSNSFullAccess, AmazonSSMReadOnlyAccess, AWSLambdaBasicRunRole, AWSLambdaRole.