Tutorials

How to Work with CloudQuery Syncs within Databricks

Prerequisites

This article contains references to GitHub repositories accessible to paying customers only. You will be able to set up CloudQuery syncs on Databricks but you will not be able to run CloudQuery transformations to get the full asset inventory.

Setting up Databricks Secrets

We'll be using secrets to store all authentication and other sensitive data. We'll be using these when we configure the CloudQuery sync.

The easiest way to create secrets is via the Databricks CLI, which you can install following these instructions: https://docs.databricks.com/aws/en/dev-tools/cli/install

Before being able to make requests via the CLI, run Databricks auth login and follow the steps.

Before creating the secrets, you'll have to create a "scope" for them. You can call it default or whatever you choose. Use Databricks secrets create-scope to create it.

Once the scope is created, you can use this to create each secret, e.g.:

databricks secrets put-secret default DATABRICKS_CATALOG --string-value "sample_catalog"

These are the secrets we need:

  • AWS authentication in order to request the data to be synced across (the AWS login screen should have them):
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
CLOUDQUERY_API_KEY
  • A Catalog name and Schema name within Databricks where CloudQuery should sync the data:
DATABRICKS_CATALOG
DATABRICKS_SCHEMA
  • The necessary environment information to connect to Databricks:
DATABRICKS_ACCESS_TOKEN  // Read note below
DATABRICKS_HOSTNAME // e.g.: https://xxxxxxx.cloud.databricks.com
DATABRICKS_HTTP_PATH // The SQL path to your warehouse e.g. /sql/1.0/warehouses/xxxxxx
DATABRICKS_STAGING_PATH // Read note below

Create the Access Token by going to: Settings > Developer > Access Tokens > Manage

Databricks settings page showing how to generate a personal access token for API authentication

As the staging path, create a Volume within your catalog, copy its address and save it into the DATABRICKS_STAGING_PATH secret.

Databricks Unity Catalog volume browser showing the staging path for CloudQuery sync data

Running the sync

We'll be syncing AWS data using the CloudQuery CLI via a Databricks Job.

Create a new Job and configure it as a Python script; the code for this job is available at: https://github.com/cloudquery/databricks-simple-cli-job

Databricks Workflows page showing the create new job form for scheduling a CloudQuery sync

You can choose to fork the repository and use the Git provider source, or just copy the main.py code within the repository onto a file on your workspace and use that.

On the Environment and Libraries section, edit it to make sure to add the py-cloudquery==0.1.3 dependency (https://pypi.org/project/py-cloudquery/0.1.3/). This contains the CloudQuery CLI.

On the Parameters section, you'll need to provide the scope name you created earlier and a spec file for your sync (something like this for AWS: https://www.cloudquery.io/hub/plugins/source/cloudquery/aws/latest/docs#configuration-examples).

There's an example spec file on the repository: https://github.com/cloudquery/databricks-simple-cli-job/blob/main/aws_to_databricks.yaml.example

Note how the spec file is using the secrets you defined earlier. These will be converted into environment variables by the job as long as you set the scope argument properly, and then expanded by CloudQuery CLI automatically.

Create a spec file onto your Workspace based on the example provided and take note of its absolute address.

Your Parameters section should thus look something like this:

["--spec","/Workspace/Users/[email protected]/aws_to_databricks.yaml","--secrets-scope","default"]

You should be able to run your job now. It should run the sync and succeed:

Databricks job run output showing a successful CloudQuery sync execution with logs

Optional: in order to validate that the sync worked properly, you can head over to the SQL editor and check the contents of the aws_ec2_instances table:

Databricks SQL editor showing query results from CloudQuery-synced cloud infrastructure tables

Transforming the data into a Cloud Asset Inventory

We'll use a different Job to transform the source sync data from AWS into a normalized Cloud Assets table that can be visualised later.

Note: this job is restricted to CloudQuery and Databricks users only, so the repository with the transformation code is private.

Create another Python-script-based job, and use this repository as source (fork it first so you're able to use it): https://github.com/cloudquery/databricks-sync-transformations

This code should already be set up to use the secrets you created for the sync, so there are no extra configuration steps. It should auto-detect your synced tables and construct a cloud_assets table from it.

There's no need to add special environments; only set the parameter that allows the job to know your secrets scope: ["--secrets-scope","default"]. You should be ready to run it straight after configuring the Git repository and it should succeed.

Optional: in order to validate that the transformation worked properly, you can head over to the SQL editor and check the contents of the cloud_assets table:

Databricks SQL query transforming raw cloud data into a unified cloud asset inventory view

Visualising the Cloud Asset Inventory

We'll be using a NodeJS-based app to visualise the cloud_assets table.

Go to Compute > Apps and create a new app; let's call it hello-frontend.

Apps are configured differently to Jobs. Our app will need to access the same secrets as the jobs, so edit the App configuration and make all the secrets available to it:

Databricks App configuration page with secret environment variables for the cloud asset dashboard

The App will also need to be able to run SQL queries against the Catalog, so enable that scope:

Databricks App permissions showing SQL warehouse scope configuration for data access

You can clone this repository and use it as source for your app: https://github.com/cloudquery/databricks-sample-app/

$ git clone [email protected]:cloudquery/databricks-sample-app.git
...
$ cd databricks-sample-app

Then you should be able to just sync the contents of the folder into your workspace, and deploy it:

$ databricks sync --watch . /Workspace/Users/[email protected]/hello-frontend
$ databricks apps deploy hello-frontend --source-code-path /Workspace/Users/[email protected]/hello-frontend

You should be able to start the app and browse your Asset Inventory 🎉

Databricks App running with a live cloud asset inventory dashboard visualizing infrastructure data

Enjoy!

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.