AWS Builder Center
Building ETL Pipelines with AWS Glue

Building ETL Pipelines with AWS Glue

Learn how AWS Glue simplifies serverless ETL using Crawlers, the Data Catalog, Glue Jobs, and PySpark to build scalable data pipelines.

Building ETL Pipelines with AWS Glue

Introduction

Data engineering often involves collecting data from different sources, transforming it into a usable format, and loading it into a destination for analytics.
AWS Glue provides a serverless way to build and run ETL pipelines without managing servers. It integrates with services such as Amazon S3, Amazon Redshift, Amazon Athena, and other AWS data services.
A typical Glue-based pipeline looks like this:
1
2
3
4
5
6
7
8
9
10
11
Data Sources
↓
AWS Glue Crawler
↓
Glue Data Catalog
↓
AWS Glue ETL Job
↓
Amazon S3 / Data Warehouse
↓
Analytics

What is AWS Glue?

AWS Glue is a serverless data integration service that helps discover, prepare, move, and transform data.
A major advantage is that you can run ETL workloads without provisioning or managing infrastructure.
Glue provides several important components:
  • Glue Data Catalog – stores metadata about datasets.
  • Glue Crawlers – automatically discover schemas.
  • Glue ETL Jobs – perform data transformations.
  • Glue Workflows – coordinate multiple Glue components.
  • Job Bookmarks – help process new data incrementally.

AWS Glue Data Catalog

The Data Catalog acts as a central metadata repository.
Instead of manually defining information about every dataset, the catalog can store details such as:
  • Database name
  • Table name
  • Column names
  • Data types
  • S3 locations
  • Partition information
For example:
1
2
3
4
5
6
7
8
9
Glue Data Catalog
↓
Database
↓
orders
↓
customer_id
order_date
amount
Services such as Amazon Athena can then use this metadata to query data stored in Amazon S3.

Glue Crawlers

A Glue Crawler scans a data source and identifies its structure.
For example, if CSV files are stored in:
1
s3://my-data-lake/orders/
a crawler can inspect the files, detect their schema, and create or update a table in the Glue Data Catalog.
This reduces the amount of manual schema management required.

Glue ETL Jobs

After discovering the data, a Glue ETL Job can transform it.
Glue supports Apache Spark, which makes it possible to use PySpark for large-scale transformations.
A simple example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()

df = spark.read.parquet("s3://my-data-lake/orders/")

clean_df = (
df.filter(df.amount > 0)
.dropDuplicates()
)

clean_df.write.mode("overwrite").parquet(
"s3://my-data-lake/processed/orders/"
)
The job reads the raw data, applies transformations, and writes the processed dataset to another location.

DynamicFrames and DataFrames

AWS Glue provides DynamicFrames, which are designed for working with data that may have inconsistent or changing schemas.
For example:
1
2
3
4
dynamic_frame = glueContext.create_dynamic_frame.from_catalog(
database="sales",
table_name="orders"
)
DynamicFrames can also be converted to Spark DataFrames when you need to use standard PySpark operations:
1
df = dynamic_frame.toDF()
For transformations that are easier to express with Spark, DataFrames are often more convenient.

Incremental ETL with Job Bookmarks

Processing the entire dataset every time a pipeline runs can be inefficient.
For example, suppose an S3 bucket contains:
1
2
3
4
orders/
├── day1.parquet
├── day2.parquet
├── day3.parquet
If a new file arrives:
1
day4.parquet
we ideally want the pipeline to process only the new data.
Glue Job Bookmarks help track previously processed data so that subsequent runs can focus on new or changed data.
This can significantly reduce processing time and unnecessary compute usage for incremental workloads.

Building a Complete ETL Pipeline

A practical Glue pipeline could look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Raw Data
↓
Amazon S3 Bronze
↓
Glue Crawler
↓
Glue Data Catalog
↓
Glue Job
(PySpark ETL)
↓
Amazon S3 Silver
↓
Athena / Redshift
↓
Analytics
The raw layer preserves the original data, while the processed layer contains cleaned and transformed data ready for analytics.

Common Transformations

ETL jobs commonly perform operations such as:
  • Removing duplicate records
  • Handling NULL values
  • Filtering invalid records
  • Changing data types
  • Joining datasets
  • Aggregating data
  • Creating derived columns
  • Partitioning datasets
For example:
1
2
3
4
5
6
7
from pyspark.sql.functions import col

result = (
df.filter(col("amount") > 0)
.dropDuplicates(["order_id"])
.withColumn("amount", col("amount").cast("double"))
)

Partitioning Data

Partitioning can improve query performance and reduce the amount of data scanned.
For example:
1
2
3
4
5
orders/
├── year=2026/
│ ├── month=01/
│ ├── month=02/
│ └── month=03/
If a query only needs data from March, the query engine can avoid scanning unrelated partitions.
However, partitioning should be designed carefully. Creating too many small partitions can increase metadata overhead and create a small-files problem.

Monitoring Glue Jobs

A production ETL pipeline should not only transform data but also provide visibility into its execution.
Useful things to monitor include:
  • Job success or failure
  • Execution time
  • Data processed
  • Worker utilization
  • Errors and exceptions
  • Number of records processed
AWS Glue integrates with Amazon CloudWatch, making it possible to monitor jobs and investigate failures.

Performance and Cost Optimization

Some practical ways to improve Glue ETL jobs include:
  • Process data incrementally instead of reprocessing everything.
  • Use columnar formats such as Parquet.
  • Partition data based on common query patterns.
  • Avoid unnecessary transformations.
  • Avoid generating excessive small files.
  • Select an appropriate worker configuration.
  • Push filtering as early as possible in the pipeline.
  • Use Job Bookmarks when the workload supports incremental processing.
These optimizations can reduce both processing time and AWS costs.

Best Practices

When building Glue pipelines:
  1. Keep raw data separate from processed data.
  2. Use the Glue Data Catalog for centralized metadata.
  3. Use Crawlers where automatic schema discovery is useful.
  4. Use PySpark for scalable transformations.
  5. Design incremental processing for large datasets.
  6. Monitor job execution and failures.
  7. Use Parquet and appropriate compression.
  8. Choose partitions based on actual query patterns.
  9. Handle bad records and schema changes carefully.
  10. Test transformations before running them on large datasets.

Conclusion

AWS Glue provides a serverless approach to building scalable ETL pipelines. By combining Glue Crawlers, the Data Catalog, Glue ETL Jobs, PySpark, and Job Bookmarks, data engineers can build pipelines that discover, transform, and process data with minimal infrastructure management.
For larger workloads, combining Glue with services such as Amazon S3 and Amazon Athena can create a flexible and cost-efficient data platform.
The key is not just building an ETL job, but designing the entire pipeline for scalability, incremental processing, reliability, and cost efficiency.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article