AWS Glue

Managed, fully serverless ETL — extract from S3 / RDS / anything JDBC, transform, load into Redshift or back to S3. Plus the Glue Data Catalog: the central metadata store that tells Athena, Redshift Spectrum and EMR what your S3 data looks like. Two things on one page: the ETL engine, and the catalog.

ETL managed, serverless hoàn toàn — extract từ S3 / RDS / bất cứ thứ gì nói JDBC, transform, load vào Redshift hoặc trả về S3. Kèm Glue Data Catalog: kho metadata trung tâm cho Athena, Redshift Spectrum và EMR biết data trên S3 có hình dạng gì. Một trang, hai thứ: engine ETL và catalog.

Reach for itNên dùng

  • Scheduled or event-driven ETL between AWS data stores, with no infrastructure to ownETL giữa các data store AWS theo lịch hoặc theo event, không phải nuôi hạ tầng
  • You need a schema for raw S3 files so Athena / Spectrum can query themCần schema cho file thô trên S3 để Athena / Spectrum query được
  • Convert formats for analytics — CSV/JSON → Parquet, repartition, deduplicateĐổi format cho analytics — CSV/JSON → Parquet, chia lại partition, khử trùng lặp
  • One shared metastore across Athena, Redshift Spectrum, EMR and Glue jobsMột metastore dùng chung cho Athena, Redshift Spectrum, EMR và Glue job

Not the right toolKhông hợp

  • Long-lived Hadoop/Spark cluster you tune yourself → EMRCluster Hadoop/Spark sống lâu, tự tinh chỉnh → EMR
  • Just querying S3, no transform → Athena (which uses the Glue catalog anyway)Chỉ query S3, không transform → Athena (vẫn dùng Glue catalog)
  • Deliver a stream to S3/Redshift with light conversion → FirehoseĐẩy stream vào S3/Redshift với chuyển đổi nhẹ → Firehose
  • Continuous DB replication / migration → DMSReplicate / migrate DB liên tục → DMS

1 · The ETL service1 · Dịch vụ ETL

Glue ETL — extract from S3 and RDS, transform in Glue, load into a Redshift data warehouse S3 bucket Amazon RDS extract Glue ETL transform fully serverless load Redshift data warehouse

Two sources in, one warehouse out, and nothing to provision in the middle.

Hai nguồn vào, một warehouse ra, và không phải provision gì ở giữa.

  • Managed extract, transform, and load (ETL) service.Dịch vụ extract, transform, and load (ETL) managed.
  • Useful to prepare and transform data for analytics.Dùng để chuẩn bị và biến đổi data cho analytics.
  • Fully serverless service — you pay for the job run, not for a cluster sitting idle.Serverless hoàn toàn — trả tiền theo lần chạy job, không phải nuôi cluster ngồi không.

Sources & targets — the wider menuSource & target — danh sách đầy đủ hơn

Glue reads and writes far more than one pair of stores — and the same store is usually valid on both sides. Glue đọc và ghi được nhiều hơn hẳn một cặp store — và thường cùng một store hợp lệ ở cả hai phía.

Glue sources and targets — S3, RDS/Aurora, DynamoDB, DocumentDB, Kinesis/MSK and any JDBC store feed Glue ETL, which writes to S3, Redshift, RDS/JDBC, DynamoDB, Kinesis/MSK and OpenSearch SOURCES TARGETS Amazon S3 RDS · Aurora DynamoDB DocumentDB · Mongo Kinesis · MSK any JDBC store Glue ETL Spark · Python shell S3 · Parquet/ORC Redshift RDS · Aurora · JDBC DynamoDB Kinesis · MSK OpenSearch accent = streaming only (Glue Streaming ETL job)

Most stores appear on both sides — Glue is a mover, not a destination. The accent boxes are only reachable from a Glue Streaming ETL job; everything else works in a normal batch job.

Hầu hết store xuất hiện ở cả hai phía — Glue chỉ là thứ vận chuyển, không phải điểm đến. Ô màu accent chỉ dùng được với job Glue Streaming ETL; còn lại chạy trong job batch bình thường.

  • Sources: S3 (CSV, JSON, Parquet, ORC, Avro, and Delta / Hudi / Iceberg tables) · RDS & Aurora · Redshift · DynamoDB · DocumentDB / MongoDB · any JDBC database (EC2 or on-prem, via a Glue connection) · Kinesis Data Streams and MSK / self-managed Kafka for streaming jobs.Source: S3 (CSV, JSON, Parquet, ORC, Avro, và bảng Delta / Hudi / Iceberg) · RDS & Aurora · Redshift · DynamoDB · DocumentDB / MongoDB · bất kỳ database JDBC nào (trên EC2 hay on-prem, qua Glue connection) · Kinesis Data Streams và MSK / Kafka tự quản cho job streaming.
  • Targets: the same list, plus OpenSearch and marketplace connectors. Writing back to S3 as Parquet is the most common "prepare for Athena / Spectrum" move.Target: đúng danh sách đó, thêm OpenSearch và connector từ marketplace. Ghi trả về S3 dạng Parquet là nước đi "chuẩn bị cho Athena / Spectrum" phổ biến nhất.
  • A job normally reads through a Data Catalog table (crawled beforehand) rather than a raw path — that's how the catalog and the ETL engine connect.Job thường đọc qua table trong Data Catalog (đã crawl trước) chứ không đọc path thô — đó là chỗ catalog và ETL engine nối vào nhau.
  • Anything inside a VPC (RDS, DocumentDB, JDBC on EC2, on-prem over DX/VPN) needs a Glue connection naming the VPC, subnet and security group.Mọi thứ nằm trong VPC (RDS, DocumentDB, JDBC trên EC2, on-prem qua DX/VPN) đều cần Glue connection khai VPC, subnet và security group.

2 · Glue Data Catalog2 · Glue Data Catalog

Glue Data Catalog — a crawler reads S3, RDS, DynamoDB and JDBC sources and writes metadata into the catalog, which Glue jobs, Athena, Redshift Spectrum and EMR then read Amazon S3 Amazon RDS DynamoDB JDBC Glue Data Crawler writes metadata Glue jobs (ETL) Glue Data Catalog Database Tables metadata Database Tables metadata schema · location metadata only — never the data Athena Redshift Spectrum EMR data discovery

The crawler is the only thing that writes. Everything on the right just reads the schema — which is why one catalog keeps Athena, Spectrum and EMR seeing the same tables.

Chỉ crawler là thứ ghi. Mọi thứ bên phải chỉ đọc schema — nhờ vậy một catalog giữ cho Athena, Spectrum và EMR nhìn thấy cùng bộ table.

  • Glue Data Catalog: catalog of datasets. Organised as databases → tables, and a table holds metadata (schema, column types, S3 location, partitions) — not the rows.Glue Data Catalog: catalog của các dataset. Tổ chức theo database → table, mỗi table giữ metadata (schema, kiểu cột, vị trí S3, partition) — không giữ dữ liệu.
  • AWS Glue Data Crawler scans Amazon S3, Amazon RDS, Amazon DynamoDB, JDBC sources and writes metadata into the catalog.AWS Glue Data Crawler quét nguồn Amazon S3, Amazon RDS, Amazon DynamoDB, JDBC rồi ghi metadata vào catalog.
  • Glue Jobs (ETL) read the catalog to know what they're transforming.Glue Jobs (ETL) đọc catalog để biết mình đang transform cái gì.
  • Data discovery consumers: Amazon Athena · Amazon Redshift Spectrum · Amazon EMR.Bên tiêu thụ cho data discovery: Amazon Athena · Amazon Redshift Spectrum · Amazon EMR.
Why this matters architecturallyVì sao điều này quan trọng về kiến trúc The catalog is the seam that makes a data lake work: data sits once in S3, and every engine (Athena, Spectrum, EMR, Glue) agrees on its schema through one catalog. If a question asks "how do Athena and EMR share table definitions?" — the answer is the Glue Data Catalog. Catalog là mối nối làm cho data lake chạy được: data nằm một chỗ trên S3, mọi engine (Athena, Spectrum, EMR, Glue) thống nhất schema qua một catalog. Nếu đề hỏi "làm sao Athena và EMR dùng chung định nghĩa table?" — đáp án là Glue Data Catalog.

3 · Running Glue in practice3 · Dùng Glue thực tế

  • Job types: Spark (distributed, the default) · Spark Streaming (reads Kinesis / MSK) · Python shell (single small script, cheap — good for calling an API or running a SQL statement). Billed per DPU-hour, per-second with a 1-minute minimum.Loại job: Spark (phân tán, mặc định) · Spark Streaming (đọc Kinesis / MSK) · Python shell (script nhỏ, rẻ — hợp để gọi API hoặc chạy một câu SQL). Tính phí theo DPU-giờ, theo giây với tối thiểu 1 phút.
  • Job bookmarks — Glue remembers what it already processed so a re-run only picks up new data. This is the answer to "avoid reprocessing the whole bucket every night".Job bookmark — Glue nhớ phần đã xử lý nên lần chạy sau chỉ lấy data mới. Đây chính là đáp án cho "đừng xử lý lại cả bucket mỗi đêm".
  • Related front-ends worth recognising: Glue Studio (visual job editor), Glue DataBrew (no-code data prep), Lake Formation (permissions on top of the same catalog).Vài giao diện liên quan nên nhận ra: Glue Studio (soạn job trực quan), Glue DataBrew (chuẩn bị data không cần code), Lake Formation (phân quyền trên cùng catalog đó).
  • To reach an RDS in a private subnet, a Glue job needs a Glue connection with VPC/subnet/security group — plus a route to S3 (VPC endpoint or NAT).Muốn chạm tới RDS trong private subnet, Glue job cần Glue connection khai VPC/subnet/security group — cộng đường ra S3 (VPC endpoint hoặc NAT).

The catalog as a Hive metastoreCatalog thay cho Hive metastore

What a metastore is: Hive — and Spark SQL, and Presto — can't query files blindly. They need a small relational database that says "table orders = these columns, these types, this S3 prefix, partitioned by day". That database is the metastore. Classic Hadoop runs it on the cluster itself (a MySQL on the master node), so it dies with the cluster and no other engine can see it. The Glue Data Catalog speaks the same API, so you point EMR at it instead. Metastore là gì: Hive — và Spark SQL, Presto — không query file một cách mù quáng được. Chúng cần một database quan hệ nhỏ nói rằng "table orders = các cột này, kiểu này, nằm ở prefix S3 này, partition theo ngày". Database đó chính là metastore. Hadoop cổ điển chạy nó ngay trên cluster (một MySQL trên master node), nên nó chết theo cluster và engine khác không nhìn thấy. Glue Data Catalog nói cùng API đó, nên bạn trỏ EMR sang nó.

Without Glue the Hive metastore runs on the EMR master node and dies with the cluster; with Glue the Data Catalog is external and shared by EMR, Athena and Redshift Spectrum WITHOUT GLUE EMR cluster Master node Hive / Spark metastore local MySQL terminate the cluster → schema gone Athena / Spectrum can't see it WITH GLUE EMR Athena Spectrum Glue Data Catalog same Hive metastore API outlives every cluster · one schema for all

Same tables, moved out of the cluster. Clusters become disposable — which is what makes a transient EMR cluster practical.

Vẫn là những table đó, nhưng dời ra ngoài cluster. Cluster trở thành thứ dùng xong bỏ — đó chính là điều làm transient EMR cluster khả thi.

Triggers & workflows — and what a "DAG" isTrigger & workflow — và "DAG" là gì

DAG = directed acyclic graph. Read it literally: a picture of steps joined by arrows (directed) where you can never come back to a step you already passed (acyclic — no loops). Each box is a crawler or a job; each arrow means "when this one finishes, start that one". A Glue workflow is exactly one of these, and Glue tracks the whole thing as a single run so you can see which box failed. DAG = directed acyclic graph (đồ thị có hướng, không chu trình). Hiểu theo đúng nghĩa đen: một hình gồm các bước nối bằng mũi tên (có hướng), và không bao giờ quay lại bước đã đi qua (không chu trình — không có vòng lặp). Mỗi ô là một crawler hoặc một job; mỗi mũi tên nghĩa là "cái này xong thì chạy cái kia". Một workflow của Glue chính là một DAG như vậy, và Glue theo dõi cả cụm như một lần chạy duy nhất nên bạn thấy được ô nào fail.

A Glue workflow as a DAG — a crawler triggers two parallel jobs, both must finish before a join job runs, which then loads Redshift crawler 02:00 schedule job A · clean job B · enrich both must succeed job C · join load Redshift arrows only ever point right — nothing loops back. That's the "acyclic" part.

One Glue workflow. The trigger types are just the different reasons an arrow fires.

Một Glue workflow. Các loại trigger chỉ là những lý do khác nhau khiến mũi tên được kích hoạt.

  • Schedule trigger — cron. "Crawl at 02:00 every day."Schedule trigger — cron. "Crawl lúc 02:00 mỗi ngày."
  • Conditional trigger — fires on the completion state of one or more upstream jobs/crawlers (SUCCEEDED, FAILED…). This is the arrow that makes chaining and the "both must succeed" join work.Conditional trigger — kích hoạt theo trạng thái hoàn tất của một hoặc nhiều job/crawler phía trước (SUCCEEDED, FAILED…). Đây là mũi tên tạo ra việc nối chuỗi và điểm gộp "cả hai phải thành công".
  • On-demand trigger — you (or an API call) start it. EventBridge can also start a workflow, e.g. on an S3 upload.On-demand trigger — bạn (hoặc một API call) khởi động. EventBridge cũng có thể khởi động workflow, ví dụ khi có file upload lên S3.
  • If the orchestration needs branching, waits, retries with backoff or human approval, reach for Step Functions instead — Glue workflows are deliberately simple.Nếu việc điều phối cần rẽ nhánh, chờ đợi, retry có backoff hay chờ người duyệt, hãy dùng Step Functions — workflow của Glue cố tình giữ đơn giản.

Exam reflexesPhản xạ khi thi

  • "Serverless ETL, no cluster to manage" → Glue. "Cluster we tune ourselves / existing Spark code" → EMR."ETL serverless, không quản cluster" → Glue. "Cluster tự tinh chỉnh / code Spark có sẵn" → EMR.
  • "Athena can't see my S3 files / no schema" → run a Glue crawler to populate the catalog."Athena không thấy file S3 / chưa có schema" → chạy Glue crawler để nạp catalog.
  • "Convert CSV to Parquet before querying" → Glue ETL job (or Firehose format conversion for streams)."Đổi CSV sang Parquet trước khi query" → Glue ETL job (hoặc Firehose format conversion cho stream).
  • "Nightly job keeps reprocessing everything" → enable job bookmarks."Job đêm cứ xử lý lại tất cả" → bật job bookmark.
  • "Glue stores my data" → trap. The catalog holds metadata only; the data stays in S3 / RDS / wherever."Glue lưu data của tôi" → bẫy. Catalog chỉ giữ metadata; data vẫn nằm ở S3 / RDS / nơi khác.