Airflow ETL for NASA APOD into Postgres
Daily Airflow DAG that pulls NASA's Astronomy Picture of the Day and loads it into Postgres.
What it does
An Airflow DAG on the Astro runtime creates an apod_data table, calls the NASA APOD API through an HTTP connection, keeps the title, explanation, URL, date and media type, and inserts the row with a Postgres hook. Postgres runs in Docker Compose for local runs; the DAG is deployed to Astronomer's Astro cloud against a Postgres database on AWS RDS.
What was built
- 01
create_table task issues CREATE TABLE IF NOT EXISTS for apod_data through PostgresHook.
- 02
SimpleHttpOperator calls planetary/apod with the API key stored in the Airflow connection extras.
- 03
TaskFlow transform keeps five fields; a load task inserts them with a parameterised query.
- 04
DAG runs @daily without catchup, locally through the Astro CLI and in Astro cloud.
The pipeline, layer by layer
Five layers, one pipeline.
L1Schedule
- Airflow @daily DAG
L2Extract
- NASA APOD API
L3Transform
- TaskFlow transform
L4Load
- Postgres load task
- PostgreSQL on AWS RDS
L5Platform
- Astro cloud deployment