Automating SQL Reports with AWS Glue and Lambda


For over a year, I spent a chunk of every Monday morning running SQL queries against our ERP database, exporting the results to CSV, formatting them in Excel, and emailing them to a distribution list of managers who needed the data to plan their week. It took about two hours each time, and there were five reports. That is ten-plus hours a week on copy-paste work that added zero analytical value.

I automated the entire pipeline using AWS Glue, Lambda, and SES. Here is what I built and why I think every business analyst should learn enough cloud to do the same.

The Old Way

The manual process looked like this: connect to the database through SSMS, run a saved query, export to CSV, open in Excel, apply formatting and conditional highlighting, save as an attachment, compose an email in Outlook, attach the file, send. Repeat for the next report.

The queries themselves were solid. They had been refined over months and produced exactly what the business needed. The problem was everything that happened after the query ran. It was pure manual overhead, and it was fragile. If I was out sick on Monday, the reports did not go out. If I fat-fingered a filter, nobody caught it until someone noticed the numbers looked off mid-week.

The New Architecture

The automated pipeline has four components.

First, the source data lands in S3. I set up an extract process that pulls from the ERP database on a schedule and drops the raw data into an S3 bucket as CSV files. This runs on an EC2 instance with a cron job, though if I were building it today I would use an RDS snapshot export or a managed connector.

Second, AWS Glue handles the transformation. The Glue ETL jobs read the raw CSVs from S3, apply the same business logic that lived in my SQL queries — aggregations, filters, calculated fields — and write the cleaned output back to a different S3 prefix as formatted CSVs. Glue crawlers catalog the data so it is also queryable through Athena if anyone needs ad-hoc access.

Third, a Lambda function triggers when the transformed files land in S3. It picks up the CSV, generates a summary in the email body with the key metrics highlighted, and attaches the full file.

Fourth, SES sends the email to the distribution list. The Lambda function formats the email with HTML tables showing the top-line numbers so managers can get the headlines without even opening the attachment.

The entire pipeline runs automatically at 6 AM every Monday. By the time anyone opens their inbox, the reports are already there.

Why Business Analysts Should Learn Cloud Basics

I am not a cloud engineer. I did not come from a software development background. I learned enough AWS to automate my own pain points, and that made an outsized difference in my effectiveness.

The barrier to entry is lower than most people think. You do not need to understand VPCs and IAM policies at an expert level to build a useful automation. You need to understand S3 as a place to put files, Lambda as a way to run code when something happens, and Glue as a way to transform data. That mental model covers a surprising number of business automation use cases.

The skills that business analysts already have — understanding the data, knowing what the business needs, writing SQL — are the hard part. The cloud infrastructure is just plumbing, and AWS has made the plumbing increasingly accessible.

The Results

The ten-plus hours per week of manual work dropped to about 30 minutes of weekly monitoring to make sure nothing errored out. Over a year, that is roughly 500 hours returned to actual analysis work.

Beyond the time savings, the reliability improved dramatically. Reports go out on schedule regardless of who is in the office. The data is consistent because the transformation logic is codified, not dependent on someone remembering to apply the right Excel filter. And because the pipeline is version-controlled, any change to the business logic is tracked and reversible.

The total AWS cost runs under 20 dollars a month. The Glue jobs process small datasets and finish in minutes. The Lambda invocations are minimal. For the price of a lunch, I replaced a process that was consuming two full workdays every month.

If you are a business analyst still running manual report distribution, this kind of automation is within your reach. Start with one report. Get it working end to end. Then expand from there. The confidence you gain from shipping that first automated pipeline will change how you think about every repetitive process in your workflow.