Implementation:Astronomer Astronomer cosmos AthenaAccessKeyProfileMapping
| Knowledge Sources | |
|---|---|
| Domains | Profile_Mapping, Athena |
| Last Updated | 2026-02-07 17:00 GMT |
Overview
Concrete tool for mapping Airflow aws connections to dbt athena profiles provided by astronomer-cosmos.
Description
The AthenaAccessKeyProfileMapping maps an Airflow aws connection to a dbt athena profile. It translates connection parameters (host, login, password, schema, port, extras) into the YAML structure that dbt expects in `profiles.yml`. This is a community-contributed adapter (`is_community=True`). It extracts the AWS access key and secret key from the Airflow connection and maps them to the athena profile fields including region, s3_staging_dir, database, and schema.
Usage
Use this profile mapping when configuring Cosmos to run dbt commands against an Athena backend. Assign it to `ProfileConfig(profile_mapping=...)` when the target Airflow connection uses the `aws` connection type.
Code Reference
Source Location
- Repository: Astronomer_Astronomer_cosmos
- File: cosmos/profiles/athena/access_key.py
Signature
class AthenaAccessKeyProfileMapping(BaseProfileMapping):
airflow_connection_type: str = "aws"
dbt_profile_type: str = "athena"
is_community: bool = True
Import
from cosmos.profiles.athena import AthenaAccessKeyProfileMapping
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conn_id | str | Yes | Airflow connection ID for Athena (aws 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.athena import AthenaAccessKeyProfileMapping
profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=AthenaAccessKeyProfileMapping(conn_id="aws_default"),
)