Implementation:Astronomer Astronomer cosmos RedshiftUserPasswordProfileMapping
| Knowledge Sources | |
|---|---|
| Domains | Profile_Mapping, Redshift |
| Last Updated | 2026-02-07 17:00 GMT |
Overview
Concrete tool for mapping Airflow redshift connections to dbt redshift profiles provided by astronomer-cosmos.
Description
The RedshiftUserPasswordProfileMapping maps an Airflow redshift connection to a dbt redshift profile. It translates connection parameters (host, login, password, schema, port, extras) into the YAML structure that dbt expects in `profiles.yml`. It maps host, port, user, password, dbname, and schema from the standard Airflow Redshift connection fields to the corresponding dbt redshift profile fields. The password is treated as a secret field and passed via an environment variable.
Usage
Use this profile mapping when configuring Cosmos to run dbt commands against an Amazon Redshift backend. Assign it to `ProfileConfig(profile_mapping=...)` when the target Airflow connection uses the `redshift` connection type.
Code Reference
Source Location
- Repository: Astronomer_Astronomer_cosmos
- File: cosmos/profiles/redshift/user_pass.py
Signature
class RedshiftUserPasswordProfileMapping(BaseProfileMapping):
airflow_connection_type: str = "redshift"
dbt_profile_type: str = "redshift"
Import
from cosmos.profiles.redshift import RedshiftUserPasswordProfileMapping
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conn_id | str | Yes | Airflow connection ID for Redshift |
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.redshift import RedshiftUserPasswordProfileMapping
profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=RedshiftUserPasswordProfileMapping(conn_id="redshift_default"),
)