Tutorials

Using CloudQuery Within Apache Airflow

If your team's workflow is based on Apache Airflow, introducing CloudQuery syncs into it is simple!

In this blog post, we'll go through setting up a basic Airflow DAG that syncs the whole catalog of xkcd comics into a local SQLite database using the SQLite destination integration. This DAG can be run entirely locally, and you don't need to pre-download CloudQuery (although if you'd like to, you can download CloudQuery here), SQLite or log in to anything.

Airflow DAG diagram showing two tasks: downloading CloudQuery binary and syncing xkcd comics to SQLite

We're gonna define two tasks in our DAG:

  • Download CloudQuery binary: it will inspect the host's OS & ARCH and get the appropriate binary for the supplied version.
  • Run the Sync: it will read our spec and run the CloudQuery sync.

The DAG will require two parameters:

Airflow DAG configuration panel showing required parameters for the CloudQuery sync
  1. The version of the CloudQuery binary. It defaults to the current latest release: v6.4.1.
  2. The path to the sync's specification file. It defaults to the folder where the dag file is.

Let's use this basic spec, which uses xkcd as a source and SQLite as a destination

---
kind: source
spec:
name: 'xkcd'
path: 'cloudquery/xkcd'
version: 'v1.0.6'
tables: ['*']
destinations:
- 'sqlite'
spec:
---
kind: destination
spec:
name: sqlite
path: cloudquery/sqlite
registry: cloudquery
version: 'v2.9.4'
spec:
# Make sure to use an absolute path here, because it's
# unlikely that Airflow will run this job as your user.
connection_string: '/your/user/path/Desktop/newdatabase.db'

The code required to run the sync is surprisingly simple:


# Task to run the CloudQuery sync command
@task(
dag=dag,
task_id='run_xkcd_to_sqlite_sync',
doc_md="""### Run xkcd to SQLite Sync
This task runs the CloudQuery sync command using the provided `spec_file_path`
parameter to sync xkcd data into a SQLite database.
It uses the path of the CloudQuery binary from the previous task.
""")
def run_xkcd_to_sqlite_sync(spec_file_path: str, cloudquery_path: str):
result = subprocess.run(
[cloudquery_path, 'sync', spec_file_path], capture_output=True
)
if result.returncode != 0:
raise Exception(
f"CloudQuery sync failed with return code {result.returncode}." +
" Output: {result.stdout.decode()}"
)

Upon running the DAG in the Airflow UI, the download task succeeds:

Airflow task logs showing CloudQuery binary download progress and completion

You can visualize the DAG and wait until it completes:

Airflow UI showing the CloudQuery DAG with task dependencies visualized as a graph

And voilà! The whole xkcd catalog is in our local SQLite database!

SQLite query results showing xkcd comic data synced by CloudQuery including titles, URLs, and metadata

Check the full example here: https://github.com/cloudquery/airflow-dag-cloudquery

Try CloudQuery yourself

Self-hosted, open source, and free to start. Or schedule a demo to see the managed version.

Related posts

Tutorials

How to Automatically Update CloudQuery Integrations with Renovate

Configure Renovate to automatically update CloudQuery integration versions in your YAML files using the CloudQuery Hub API as a custom datasource.

Matthew M

Matthew M

May 20, 2026

AWS

Security

Tutorials

Finding AWS Unrestricted Outbound Access in 2026: EC2, Lambda, and Beyond

Find EC2, Lambda, and ECS Fargate resources with unrestricted outbound access in AWS using SQL. Why egress controls still break attack chains in 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Security

Tutorials

AWS IAM Identity Center with Google Workspace as an IdP: 2026 Step-by-Step Guide

Set up AWS IAM Identity Center with Google Workspace: SAML authentication, SCIM user provisioning, and group sync with CLI or ssosync. Updated for 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

GCP

Security

Tutorials

Creating Cross-Project Service Accounts in GCP (Console + gcloud CLI)

Create a GCP service account that reads across all your projects with one credential. Covers gcloud CLI, org-level vs.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Cloud Infrastructure

Security

Tutorials

Integrate AbuseIPDB Threat Intelligence with CloudQuery

Enrich your cloud asset inventory with AbuseIPDB threat intelligence to identify public cloud IPs with known abuse reports.

Joe Karlsson

Joe Karlsson

April 20, 2026

AWS

Cloud Infrastructure

Tutorials

How to Query ipinfo.io Data with CloudQuery

Learn how to enrich your cloud asset inventory with ipinfo.io IP geolocation and threat intelligence data using CloudQuery.

Joe Karlsson

Joe Karlsson

April 20, 2026

AWS

Security

Tutorials

AWS IAM Identity Center (Formerly AWS SSO): The Complete 2026 Guide

AWS IAM Identity Center replaced AWS SSO in 2022. Learn how to set it up, configure permission sets, use the AWS CLI, and audit access with CloudQuery.

Joe Karlsson

Joe Karlsson

April 6, 2026

AWS

Tutorials

AWS Pinpoint Is Being Deprecated: How to Assess Your Migration Scope

AWS Pinpoint reaches end of support October 2026. Query your Pinpoint usage across all accounts to find what needs migrating before the deadline.

Joe Karlsson

Joe Karlsson

March 24, 2026

Tutorials

Moving Data from PostgreSQL to MotherDuck

How to sync PostgreSQL data to MotherDuck using CloudQuery, with both one-off batch and continuous CDC streaming options for serverless analytics.

Herman Schaaf

Herman Schaaf

March 13, 2026

Own your pipeline.
Own your data.