Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Astronomer Astronomer cosmos GoogleCloudServiceAccountKeyfileProfileMapping

From Leeroopedia


Knowledge Sources
Domains Profile_Mapping, BigQuery
Last Updated 2026-02-07 17:00 GMT

Overview

Concrete tool for mapping Airflow google_cloud_platform connections to dbt bigquery profiles (service-account-json method) provided by astronomer-cosmos.

Description

The GoogleCloudServiceAccountDictProfileMapping maps an Airflow google_cloud_platform connection to a dbt bigquery profile using the service-account-json authentication method. It extracts the service account keyfile contents as a JSON dictionary from the Airflow connection extras and inlines them into the dbt profile. The keyfile JSON is treated as a secret field and is passed via environment variables at runtime.

Usage

Use this profile mapping when configuring Cosmos to run dbt commands against a BigQuery backend with an inline service account key (no file on disk). Assign it to `ProfileConfig(profile_mapping=...)` when the target Airflow connection uses the `google_cloud_platform` connection type with the keyfile JSON stored in extras.

Code Reference

Source Location

Signature

class GoogleCloudServiceAccountDictProfileMapping(BaseProfileMapping):
    airflow_connection_type: str = "google_cloud_platform"
    dbt_profile_type: str = "bigquery"
    dbt_profile_method: str = "service-account-json"

Import

from cosmos.profiles.bigquery import GoogleCloudServiceAccountDictProfileMapping

I/O Contract

Inputs

Name Type Required Description
conn_id str Yes Airflow connection ID for BigQuery (google_cloud_platform type)

Outputs

Name Type Description
profile dict dbt profile YAML dictionary
env_vars dict Environment variables for secret fields

Usage Examples

from cosmos.config import ProfileConfig
from cosmos.profiles.bigquery import GoogleCloudServiceAccountDictProfileMapping

profile_config = ProfileConfig(
    profile_name="default",
    target_name="dev",
    profile_mapping=GoogleCloudServiceAccountDictProfileMapping(conn_id="google_cloud_default"),
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment