DEV Community

Muhammad Umair Ashraf
Muhammad Umair Ashraf

Posted on

Building a Real-Time Data Lakehouse with Amazon S3 Tables, Apache Iceberg, AWS Glue, and Athena

Apache Iceberg, AWS Glue, Amazon Athena, and the architecture behind modern analytics.

Imagine running an e-commerce platform that receives thousands of orders every minute.

Customers are browsing products, placing orders, making payments, and requesting cancellations.

Your business team wants answers:

  • Which products are selling fastest?
  • Which region is generating the most revenue?
  • How many orders were cancelled in the last hour?
  • Are customer purchasing trends changing?

Your organization has plenty of data, but getting useful insights from it is not always easy.

Data is scattered across databases, application logs, event streams, and object storage.

You need a platform that can ingest data, manage changing records, maintain consistency, and make information available for analytics.

This is where Amazon S3 Tables becomes interesting.

By combining Amazon S3 Tables, Apache Iceberg, AWS Glue, and Amazon Athena, we can build a modern data lakehouse with managed table storage, data processing, and SQL analytics.

Let's explore the architecture.

1. From Data Lake to Data Lakehouse

Amazon S3 has long been a popular foundation for data lakes.

Organizations use it to store structured, semi-structured, and unstructured data.

Common formats include:

  • Apache Parquet
  • JSON
  • CSV
  • Avro

However, storing files is different from managing transactional analytical tables.

What happens when an existing record needs to be updated?

How do you maintain consistent table versions?

What happens when your schema changes?

How can multiple analytical engines work with the same datasets?

This is why open table formats such as Apache Iceberg have become important.

Iceberg introduces a metadata layer that manages table snapshots, manifests, schemas, and data files.

Amazon S3 Tables builds on this concept by providing purpose-built storage for Apache Iceberg tables with managed maintenance.

2. Understanding Amazon S3 Tables

Amazon S3 Tables is designed specifically for analytical table data.

Unlike a general-purpose S3 bucket, an S3 table bucket stores tables as managed resources.

These tables use Apache Iceberg.

Key capabilities include:

  • ACID transactions
  • Schema evolution
  • Snapshot-based time travel
  • Row-level updates and deletes
  • Integration with compatible analytics engines
  • Automated table maintenance

One particularly useful feature is automated maintenance.

Amazon S3 Tables can perform operations such as:

Compaction: Combines smaller data files into fewer, larger files.

Snapshot management: Manages historical table snapshots according to configured retention policies.

Unreferenced file removal: Cleans up files that are no longer referenced by the table.

This reduces the operational effort required to maintain large analytical tables.

Official documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables.html

3. Designing the Lakehouse Architecture

Let's build an architecture for our e-commerce platform.

The goal is to ingest order events, transform them, store them in Iceberg tables, and make the data available for analytics.

          DATA SOURCES
  ----------------------------
  E-commerce Applications
  Transaction Databases
  Customer Activity
  Application Events
  ----------------------------
              |
              v
       DATA INGESTION
  ----------------------------
  Amazon Data Firehose
  AWS Glue Streaming
  AWS Lambda
  ----------------------------
              |
              v
        AMAZON S3 TABLES
  ----------------------------
          Table Bucket
              |
        Apache Iceberg
  ----------------------------
              |
              v
           AWS GLUE
  ----------------------------
      Data Transformation
       Data Validation
         ETL Processing
  ----------------------------
              |
              v
        AMAZON ATHENA
  ----------------------------
          SQL Queries
      Historical Analysis
  ----------------------------
              |
              v
        AMAZON QUICK SUITE
  ----------------------------
          Dashboards
           Reporting
  ----------------------------
Enter fullscreen mode Exit fullscreen mode

Each service has a specific responsibility.

AWS Service Responsibility
Amazon S3 Tables Managed Iceberg table storage
Apache Iceberg Open table format and transactional metadata
AWS Glue Data integration and ETL
Amazon Athena Serverless SQL analytics
Amazon Data Firehose Streaming data delivery
AWS Lambda Event-driven processing
Amazon Quick Suite Business intelligence and visualization

The ingestion and processing services should be selected according to event volume, latency requirements, and application architecture.

4. Apache Iceberg: The Technology Behind the Tables

Consider a simple order record:

{
  "order_id": 1001,
  "customer_id": 501,
  "amount": 250.00,
  "status": "PENDING"
}
Enter fullscreen mode Exit fullscreen mode

A few minutes later, the payment is confirmed.

The order status changes to COMPLETED.

With a traditional file-based data lake, updating an existing record can require custom logic to rewrite files and manage metadata.

With Apache Iceberg, compatible query engines can perform transactional updates while maintaining consistent table snapshots.

This is useful for:

  • Financial transactions
  • Customer records
  • Inventory management
  • Order processing
  • Change data capture (CDC)

Iceberg helps transform a collection of files into a managed analytical table.

5. Ingesting Data into Amazon S3 Tables

Our e-commerce application generates order events continuously.

For example:

{
  "order_id": 1001,
  "customer_id": 501,
  "product_id": 301,
  "quantity": 2,
  "amount": 250.00,
  "status": "COMPLETED",
  "order_timestamp": "2026-11-24T10:15:00Z"
}
Enter fullscreen mode Exit fullscreen mode

We need a reliable way to ingest these events.

Option A: Amazon Data Firehose

Amazon Data Firehose provides managed streaming data delivery.

It can support S3 Tables ingestion through supported configurations and integrations.

Option B: AWS Glue Streaming

AWS Glue Streaming uses Spark Structured Streaming to process continuous data streams.

It can transform incoming events and write them to compatible Iceberg tables.

Option C: AWS Lambda

Lambda can process application events and connect them to ingestion workflows.

It is useful for lightweight event-driven processing and integrations.

Remember that ingestion pipelines also need to handle retries, duplicate events, schema changes, and delivery failures.

Near-real-time ingestion does not automatically mean instant analytics. End-to-end data freshness depends on the entire pipeline.

6. Transforming Data with AWS Glue

Raw data is rarely ready for business analytics.

Some records might contain missing customer IDs.

Others might have invalid timestamps or negative amounts.

AWS Glue helps transform incoming information into trusted analytical datasets.

A simplified PySpark transformation might look like this:

from pyspark.sql.functions import col, current_timestamp

# Assume raw_orders is an existing Spark DataFrame.

clean_orders = raw_orders \
    .filter(col("order_id").isNotNull()) \
    .filter(col("amount") >= 0) \
    .withColumn(
        "processed_at",
        current_timestamp()
    )

clean_orders.show(10)
Enter fullscreen mode Exit fullscreen mode

This example demonstrates the transformation logic.

A complete Glue job also requires the appropriate Iceberg catalog configuration, Spark extensions, table destination, and IAM permissions.

AWS Glue supports Apache Iceberg through its native data lake framework integration.

For S3 Tables:

  • AWS Glue 5.0 or later is required for S3 Tables support.
  • Iceberg V3 requires AWS Glue 5.1 or later.
  • Iceberg V3 data types require AWS Glue 6.0 or later.

Documentation:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-integrating-glue.html

7. Querying the Lakehouse with Amazon Athena

Now comes the interesting part.

Our data is available in Iceberg tables.

The business team wants answers.

Amazon Athena provides serverless SQL analytics without requiring you to provision database servers.

Once S3 Tables is integrated with the AWS Glue Data Catalog and the required permissions are configured, you can query supported tables through Athena.

Calculate total revenue

SELECT
    SUM(amount) AS total_revenue
FROM orders
WHERE status = 'COMPLETED';
Enter fullscreen mode Exit fullscreen mode

Find the top-selling products

SELECT
    product_id,
    SUM(quantity) AS total_units_sold,
    SUM(amount) AS total_revenue
FROM orders
WHERE status = 'COMPLETED'
GROUP BY product_id
ORDER BY total_revenue DESC
LIMIT 10;
Enter fullscreen mode Exit fullscreen mode

Analyze hourly sales

SELECT
    date_trunc('hour', order_timestamp) AS sales_hour,
    COUNT(*) AS total_orders,
    SUM(amount) AS revenue
FROM orders
GROUP BY 1
ORDER BY 1;
Enter fullscreen mode Exit fullscreen mode

These examples assume that the orders table is available in the selected Athena catalog and database.

Athena makes it easier for analysts to explore data without managing database infrastructure.

Documentation:

https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg.html

8. Handling Updates and Deletes

Real business data changes.

An order can be cancelled, a payment can be corrected, or inventory information can be updated.

Apache Iceberg supports transactional row-level operations through compatible engines.

For example, supported Athena engine versions can execute operations such as:

UPDATE orders
SET status = 'CANCELLED'
WHERE order_id = 1001;
Enter fullscreen mode Exit fullscreen mode

You can also delete records:

DELETE FROM orders
WHERE order_id = 1001;
Enter fullscreen mode Exit fullscreen mode

And insert new records:

INSERT INTO orders (
    order_id,
    customer_id,
    amount,
    status
)
VALUES (
    1002,
    502,
    150.00,
    'COMPLETED'
);
Enter fullscreen mode Exit fullscreen mode

Always validate the selected Athena engine version and operation support before using these statements in production.

9. Time Travel: Accessing Historical Data

Imagine your finance team discovers that yesterday's revenue report has changed.

They need to investigate what happened.

Apache Iceberg maintains snapshots of table states.

Supported query engines can access historical table versions using time travel.

For example, Athena supports timestamp-based queries:

SELECT *
FROM orders
FOR TIMESTAMP AS OF
    TIMESTAMP '2026-11-24 09:00:00';
Enter fullscreen mode Exit fullscreen mode

This is useful for:

  • Historical analysis
  • Auditing data changes
  • Investigating pipeline errors
  • Comparing table versions
  • Debugging unexpected updates

Historical access depends on snapshot retention. If a snapshot expires and its underlying data is removed, that version may no longer be available.

10. Automated Maintenance with Amazon S3 Tables

Small files are a common challenge in data lake architectures.

Continuous ingestion can generate thousands of small files.

Too many files can increase metadata overhead and affect query performance.

Amazon S3 Tables helps reduce this operational burden through managed maintenance.

Its maintenance capabilities include:

File compaction: Combines smaller files into larger files.

Snapshot management: Manages historical table versions according to configured retention policies.

Unreferenced file removal: Cleans up files that are no longer referenced by the table.

These capabilities help maintain table health without requiring teams to manage every maintenance operation themselves.

Documentation:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-maintenance.html

11. Building Business Intelligence Dashboards

Once your tables are accessible through Athena, you can build business intelligence workflows.

For example, a sales dashboard might display:

Sales Performance

  • Total revenue
  • Completed orders
  • Cancelled orders
  • Average order value

Product Analytics

  • Top-selling products
  • Revenue by category
  • Product demand trends

Customer Analytics

  • New customers
  • Repeat purchases
  • Customer activity

Operational Analytics

  • Order processing trends
  • Payment status
  • Regional performance

Amazon Quick Suite can help teams explore and visualize data from supported analytics sources.

Dashboard freshness depends on ingestion latency, processing frequency, query execution, and refresh configuration.

12. Security and Governance

A production lakehouse needs strong security.

Consider these practices:

  • IAM: Apply least-privilege permissions to table buckets, namespaces, and tables.
  • AWS Lake Formation: Use fine-grained governance where supported and configured.
  • Encryption: Protect data at rest and in transit.
  • AWS CloudTrail: Track supported API activity.
  • Data classification: Identify sensitive information before granting access.

One important detail: S3 Tables uses the s3tables service namespace, which is different from the standard s3 namespace.

Your IAM policies must include the correct service actions and resource types.

13. Performance and Cost Optimization

A modern lakehouse should also be cost-conscious.

Area Best Practice
Storage Review retention and storage usage
Compaction Monitor maintenance activity
Queries Avoid unnecessary full-table scans
Data layout Design appropriate partitioning
Ingestion Use suitable batch sizes
Analytics Monitor Athena data scanned
Security Apply least-privilege permissions

For example, instead of selecting every column:

SELECT *
FROM orders;
Enter fullscreen mode Exit fullscreen mode

Select only the columns you need:

SELECT
    order_id,
    customer_id,
    amount
FROM orders
WHERE order_timestamp >=
    TIMESTAMP '2026-11-01 00:00:00';
Enter fullscreen mode Exit fullscreen mode

Also account for S3 Tables storage, requests, monitoring, maintenance, Glue jobs, Athena queries, and ingestion costs.

Review current pricing before deploying:

https://aws.amazon.com/s3/pricing/

14. S3 Tables vs. Traditional S3-Based Iceberg Tables

Should you always choose S3 Tables?

Not necessarily.

Traditional Iceberg tables stored in general-purpose S3 buckets remain a valid architecture.

Capability Traditional S3 + Iceberg Amazon S3 Tables
Storage General-purpose S3 bucket Dedicated table bucket
Table format Apache Iceberg Apache Iceberg
Maintenance You manage it Automated maintenance
Storage control More direct control Managed experience
Operations More responsibility Less operational overhead

Choose traditional S3-based Iceberg when you need more direct control over storage organization and maintenance.

Choose S3 Tables when you want a managed Iceberg experience with automated maintenance and AWS analytics integrations.

The best choice depends on your workload and operational requirements.

15. Production Deployment Checklist

Before deploying your lakehouse, consider the following:

  • [ ] Create separate development, testing, and production environments.
  • [ ] Create S3 table buckets and namespaces.
  • [ ] Integrate S3 Tables with AWS Glue Data Catalog.
  • [ ] Configure IAM and required Lake Formation permissions.
  • [ ] Verify Glue and Iceberg version compatibility.
  • [ ] Select your ingestion architecture.
  • [ ] Implement data validation and quality checks.
  • [ ] Configure retry and checkpoint behavior where applicable.
  • [ ] Test inserts, updates, deletes, and historical queries.
  • [ ] Review snapshot retention and maintenance settings.
  • [ ] Monitor Athena query performance.
  • [ ] Review storage and processing costs.
  • [ ] Test recovery and data-access procedures.

Final Thoughts

Let's return to our e-commerce business.

It started with a simple requirement: understand what was happening across the business.

But the engineering challenge was much bigger.

The company needed to ingest events, manage changing records, maintain consistent tables, support analytical queries, and make insights available to decision-makers.

Amazon S3 Tables brings managed Apache Iceberg capabilities to Amazon S3.

AWS Glue helps process and transform data.

Amazon Athena makes SQL analytics accessible.

Amazon Quick Suite helps turn analytical results into business intelligence.

Together, these services provide a strong foundation for a modern data lakehouse.

The biggest opportunity is not simply storing more data.

It is making data easier to manage, trust, discover, and analyze.

A modern data lake should not just remember what happened. It should help your business understand what is happening.

What would you build with Amazon S3 Tables: a real-time sales analytics platform, an IoT lakehouse, or a centralized enterprise analytics platform?

Share your thoughts in the comments!


References

Top comments (0)