Back to Blog
ETLAWSData

Serverless Data Pipeline with AWS Glue, Athena

Building a Secure, Serverless Data Pipeline with AWS Glue, Athena, and infrastructure as code

Building a Secure, Serverless Data Pipeline with AWS Glue, Athena, and Pulumi

ETL Pipeline Architecture

In the modern data landscape, unlocking the value hidden within application logs is a massive competitive advantage. However, building a Business Intelligence (BI) platform to harness this data comes with significant engineering and security challenges. During my time as a Dev Lead, I spearheaded the development of a comprehensive data pipeline designed to ingest, transform, and analyze data while strictly adhering to compliance standards.

Here is a deep dive into how we built a scalable data lake on AWS, handled complex ETL processes, and managed our entire infrastructure using Pulumi.

The Challenge: Unlocking Log Data Securely

Our primary goal was to empower the Data Science and Business Analytics teams with easy access to operational and business metrics. The raw data resided in AWS CloudWatch logs, which were difficult to query at scale and contained sensitive information. Furthermore, as a SOC-2 compliant company, maintaining strict data privacy and security was non-negotiable. We needed a robust, automated pipeline to ingest this data, scrub it of Personally Identifiable Information (PII), and make it easily queryable via SQL for dashboarding and reporting.

Designing the AWS Architecture

To build a highly available and scalable Business Intelligence platform, we leveraged a suite of AWS services, ensuring that each component adhered to the principle of least privilege using AWS IAM (Identity and Access Management).

  • Amazon S3 (Simple Storage Service): Served as our central data lake. S3 provided the highly durable, low-cost storage needed to hold massive amounts of transformed log data.
  • AWS Glue: Acted as our fully managed, serverless data integration service. We used Glue (running Apache Spark under the hood) to perform the heavy lifting of our ETL (Extract, Transform, Load) tasks.
  • Amazon Athena: Provided serverless, interactive query capabilities. By pointing Athena (based on Presto) at our S3 data lake, our analysts could query vast datasets using standard SQL without needing to manage any database clusters.
  • Amazon EC2 & AWS SSM (Systems Manager): While the core data pipeline was serverless, we utilized EC2 instances for specific internal orchestration tools and bastion hosts. AWS SSM was critical here, allowing us to manage these instances securely without opening inbound SSH ports, maintaining our strict security posture.

The ETL Process: JSON, Parquet, and PII Scrubbing

The core of this project was the ETL pipeline. Raw logs generated by our applications were ingested from CloudWatch in highly nested, verbose JSON formats. Querying raw JSON directly is computationally expensive and slow.

Here is how we structured the transformation:

  1. Data Extraction: AWS Glue jobs were triggered to extract the raw JSON logs on a scheduled basis.
  2. PII Removal (SOC-2 Compliance): Before any data was written to the analytics layer, it had to be sanitized. The Glue jobs executed custom Python/Spark scripts to scan the data and mask, hash, or completely strip out Personally Identifiable Information (PII). This ensured that our data lake was entirely sanitized and aligned with our SOC-2 data privacy requirements.
  3. Transformation to Parquet: Once sanitized, the data was flattened and converted from JSON into Parquet format. Parquet is a columnar storage format that is highly optimized for analytical queries. It significantly reduced our S3 storage footprint and drastically improved Athena query performance by allowing the engine to scan only the necessary columns rather than entire rows.

Infrastructure as Code (IaC) with Pulumi

Managing cloud infrastructure manually via the AWS Console is a recipe for configuration drift and security vulnerabilities. To ensure our BI platform was reproducible and secure, we fully deployed it using Pulumi.

Pulumi is a powerful Infrastructure as Code tool and a modern competitor to Terraform and AWS CloudFormation. Unlike traditional IaC tools that rely on domain-specific languages (like HCL) or static YAML/JSON, Pulumi allows you to define your infrastructure using familiar programming languages like Python or TypeScript.

Key benefits of using IaC for this project included:

  • Code Review for Infrastructure: Because our infrastructure was written in actual code, every change to our IAM roles, S3 buckets, or Glue jobs went through standard Pull Request (PR) reviews. This allowed us to catch misconfigurations and security issues before they hit production.
  • Environment Parity: We were able to effortlessly spin up identical dev, staging, and prod environments. This gave developers a safe sandbox to test new ETL scripts without impacting the production data lake.
  • Seamless Integration: Pulumi integrated perfectly into our existing CI/CD pipelines (managed via GitHub Actions), allowing for automated, predictable deployments.

The Business Impact

The implementation of this pipeline fundamentally changed how the company interacted with its data. By transforming raw, unmanageable JSON logs into structured, sanitized Parquet files, we unlocked previously inaccessible insights.

The Data Science and Business Analytics teams could now write standard SQL queries in Athena to explore the data, run further downstream ETLs, and feed this information directly into BI dashboards. Ultimately, this provided upper management with real-time, easy visibility into key business metrics, all while maintaining the rigorous security standards required of a SOC-2 certified organization.