Project 07 · Serverless on AWS

Serverless Data Pipeline on AWS

Point-of-sale systems in 140 stores drop sales files into Amazon S3 throughout the day. Each new file triggers an EventBridge rule that starts a Step Functions workflow: a Lambda function validates the file, and an AWS Glue job merges its rows into an Apache Iceberg table in the Glue Data Catalog. Athena queries the table directly and Redshift Serverless refreshes the reporting views every 15 minutes. Nothing runs between files, so the whole pipeline costs about $14 a day.

  • Amazon S3
  • Amazon EventBridge
  • AWS Step Functions
  • AWS Lambda
  • AWS Glue
  • Amazon Athena
  • Amazon Redshift Serverless
Sample data Last 30 days · Sep 7 – Oct 6, 2026 Download data (CSV)

Workflow executions by outcome

Step Functions, one execution per file

Sales by region

From the processed files, 30 days

Lambda invocations

Per day

Lambda error rate

Per day, with the alert threshold

Daily cost by service

Everything the pipeline uses, in USD

Glue job run time

p50 and p95 per day

Latest executions

Oct 6, most recent first

How it works

Event-driven from end to end: a file arrives, a workflow runs, and then everything scales back to zero.

  1. 01 · Land

    Amazon S3

    POS systems upload about 630 sales files a day to s3://sales-landing/<store>/<date>/.

  2. 02 · Trigger

    Amazon EventBridge

    An Object Created rule starts one Step Functions execution per file.

  3. 03 · Validate

    AWS Lambda

    Checks the header, row count and encoding. Bad files move to a quarantine prefix with the reason.

  4. 04 · Transform

    AWS Glue

    A Spark job types the rows and merges them into an Iceberg table on transaction id.

  5. 05 · Catalog

    Glue Data Catalog

    Every Iceberg commit updates the catalog, so new rows are queryable immediately.

  6. 06 · Serve

    Athena · Redshift Serverless

    Athena for ad hoc questions; Redshift refreshes reporting views every 15 minutes.

  • Pay per file. No cluster waits for work. Lambda and Glue start when a file lands and stop when it is done; backfills run on Glue Flex at a lower price.
  • Retries live in the workflow. Step Functions retries throttled Lambda calls and Glue errors with exponential backoff before an execution is marked failed and an alert goes out.
  • Safe to run twice. The Glue job merges on transaction_id and sku, so a file processed twice, by a retry or a manual rerun, does not double the sales.
  • Bad files don't block good ones. A file that fails validation goes to quarantine with its reason and the next file runs normally. Store support gets a daily list.

Data model

Raw files keep their CSV layout; the Iceberg table is what Athena and Redshift query.

s3://sales-landingCSV files from POS systems
store_id / register_idstring
Where the sale happened
transaction_idstring
Unique per sale within a store
sold_atstring
Local timestamp, parsed by Glue
sku / quantity / unit_pricestring
One row per item
payment_typestring
card, cash, gift_card, mobile
sales.transactionsIceberg table · Glue Data Catalog · days(sold_at), store_id
transaction_id / skustring
Merge key
store_idint
Store
sold_attimestamp
Converted to UTC
quantity / unit_priceint / decimal(10,2)
Typed values
source_filestring
The S3 key it came from
pipeline_dailyRollup · the CSV download
datedate
Day
files / executions_*int
Files received and how their workflows ended
lambda_invocations / lambda_errorsint
Lambda activity
glue_p50_s / glue_p95_sint
Glue run time
cost_*_usd / sales_usddecimal
Cost by service, and sales in the files

Key code

The Step Functions workflow, the validation Lambda and the Glue job.

Step Functions workflow (Amazon States Language): validate, transform, and quarantine on failure.

{
  "Comment": "Process one POS sales file from S3",
  "StartAt": "ValidateFile",
  "States": {
    "ValidateFile": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "validate-sales-file",
        "Payload": {
          "bucket.$": "$.detail.bucket.name",
          "key.$": "$.detail.object.key"
        }
      },
      "ResultSelector": { "file.$": "$.Payload" },
      "Retry": [
        {
          "ErrorEquals": ["Lambda.TooManyRequestsException", "Lambda.ServiceException"],
          "IntervalSeconds": 2,
          "MaxAttempts": 3,
          "BackoffRate": 2
        }
      ],
      "Catch": [
        { "ErrorEquals": ["InvalidFile"], "ResultPath": "$.error", "Next": "Quarantine" }
      ],
      "Next": "MergeIntoIceberg"
    },
    "MergeIntoIceberg": {
      "Type": "Task",
      "Resource": "arn:aws:states:::glue:startJobRun.sync",
      "Parameters": {
        "JobName": "merge-sales-file",
        "Arguments": {
          "--source_key.$": "$.file.key",
          "--store_id.$": "$.file.store_id"
        }
      },
      "Retry": [
        {
          "ErrorEquals": ["Glue.ConcurrentRunsExceededException", "Glue.AWSGlueException"],
          "IntervalSeconds": 30,
          "MaxAttempts": 4,
          "BackoffRate": 2
        }
      ],
      "End": true
    },
    "Quarantine": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": { "FunctionName": "quarantine-sales-file", "Payload.$": "$" },
      "Next": "Rejected"
    },
    "Rejected": {
      "Type": "Fail",
      "Error": "InvalidFile",
      "Cause": "The file failed validation and was moved to quarantine"
    }
  }
}

Engineering notes

A POS upgrade, contained

On Sep 18 a software update at one store changed the CSV header. Eleven files failed validation and went to quarantine with the reason; every other store's files kept flowing. After the store's export was fixed, the quarantined files were replayed.

The Oct 1 backfill

Reprocessing a month for an audit hit Glue's concurrent-run limit. Step Functions retried with backoff, so 31 executions finished late instead of failing; p95 Glue time that day was about 7 minutes.

About $14 a day

Glue is two-thirds of the cost. Moving backfills to Glue Flex on Sep 27 cut Glue spend by about 6% without slowing the daily files.

Minutes, not a nightly batch

Sales are queryable in Athena about six minutes after a store uploads a file, and in the Redshift reporting views within the next 15-minute refresh.

About the data. Every number on this page is sample data from a seeded generator written for this project. It is shaped to behave like a real workload, with daily peaks, late events and the odd incident, but it does not come from any employer or client. Download it as pipeline_daily.csv or read data.json.