Skip to content

aws_conn_id in RDS operators (e.g., RdsStartExportTaskOperator, RdsCreateDbSnapshotOperator) is ignored and falls back to aws_default in apache-airflow-providers-amazon>=9.6.0 #50766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 2 tasks
frobb opened this issue May 19, 2025 · 1 comment
Labels
area:providers kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet

Comments

@frobb
Copy link

frobb commented May 19, 2025

Apache Airflow Provider(s)

amazon

Versions of Apache Airflow Providers

apache-airflow-providers-amazon>=9.6.0

Apache Airflow version

2.10.1

Operating System

MWAA

Deployment

Amazon (AWS) MWAA

Deployment details

No response

What happened

In apache-airflow-providers-amazon>=9.6.0, when using RDS operators such as RdsStartExportTaskOperator or RdsCreateDbSnapshotOperator, the aws_conn_id parameter provided during operator instantiation is not being honored. Instead, the operator attempts to use the aws_default connection.
This behavior appears to be a regression from earlier versions of the provider (e.g., 8.x.x series) where the specified aws_conn_id was correctly used.
The issue seems to stem from the RdsBaseOperator's init method (from which other RDS operators inherit). In version 9.6.0 of airflow/providers/amazon/aws/operators/rds.py, the aws_conn_id parameter in the RdsBaseOperator.init signature:

class RdsBaseOperator(AwsBaseOperator[RdsHook]):
    # ...
    def __init__(
        self,
        *args,
        aws_conn_id: str | None = "aws_conn_id",  # <--- This line
        region_name: str | None = None,
        **kwargs,
    ):
        self.aws_conn_id = aws_conn_id
        self.region_name = region_name
        super().__init__(*args, **kwargs)
        # ...

This explicitly captures the aws_conn_id if passed in kwargs. Consequently, when super().init(*args, **kwargs) is called to initialize the parent AwsBaseOperator, the aws_conn_id is no longer present in kwargs. AwsBaseOperator then falls back to its own default for its aws_conn_id parameter, which is "aws_default". The hook used by the operator then incorrectly uses this default connection.

What you think should happen instead

The RDS operator should use the specific AWS connection ID provided in its aws_conn_id parameter. If a user specifies aws_conn_id="my_custom_conn", the operator should use the Airflow connection named my_custom_conn, not aws_default.

How to reproduce

  1. Prerequisites:
    Airflow version 2.10
    apache-airflow-providers-amazon==9.6.0 (or any subsequent version where this issue persists).

  2. Airflow Connections:
    In the Airflow UI, create an AWS connection named my_custom_rds_conn. The actual credentials can be placeholders for this reproduction; the existence of the named connection is key.

Ensure that there is no Airflow connection named aws_default. (Alternatively, if aws_default must exist for other reasons, ensure its credentials would obviously fail or be different from my_custom_rds_conn for the RDS operation).

  1. Minimal DAG:
    Create and run the following DAG:

    from __future__ import annotations
    
    import pendulum
    
    from airflow.models.dag import DAG
    from airflow.providers.amazon.aws.operators.rds import RdsCreateDbSnapshotOperator # Or RdsStartExportTaskOperator
    
    with DAG(
        dag_id="rds_aws_conn_id_bug_repro",
        start_date=pendulum.datetime(2025, 5, 19, tz="UTC"),
        catchup=False,
        schedule=None,
        tags=["bug-repro"],
    ) as dag:
        create_snapshot_task = RdsCreateDbSnapshotOperator(
            task_id="create_db_snapshot_bug_test",
            aws_conn_id="my_custom_rds_conn",  # Intended connection
            db_type="instance",              # Placeholder
            db_identifier="my-dummy-db-id",  # Placeholder
            db_snapshot_identifier="my-dummy-snapshot-id" # Placeholder
        )
  2. Observe:
    Trigger the DAG.
    The create_db_snapshot_bug_test task is expected to fail (as the DB identifier is a dummy).
    Inspect the logs for the failed task instance.

  3. Expected vs. Actual Outcome:
    Expected (if bug wasn't present): If my_custom_rds_conn was actually used, the error might relate to "DB instance my-dummy-db-id not found" using the (placeholder) credentials from my_custom_rds_conn.

Actual (due to bug): The task will fail with an error indicating that the connection aws_default could not be found (e.g., airflow.exceptions.AirflowNotFoundException: The conn_id aws_default isn't defined), or an equivalent Boto3/AWS SDK error if it tries to use default credential chain after failing to find aws_default. This demonstrates that the operator ignored aws_conn_id="my_custom_rds_conn" and attempted to use aws_default.

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@frobb frobb added kind:bug This is a clearly a bug area:providers needs-triage label for new issues that we didn't triage yet labels May 19, 2025
Copy link

boring-cyborg bot commented May 19, 2025

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

@frobb frobb changed the title aws_conn_id in RDS operators (e.g., RdsStartExportTaskOperator, RdsCreateDbSnapshotOperator) is ignored and falls back to aws_default in apache-airflow-providers-amazon==9.6.0 aws_conn_id in RDS operators (e.g., RdsStartExportTaskOperator, RdsCreateDbSnapshotOperator) is ignored and falls back to aws_default in apache-airflow-providers-amazon>=9.6.0 May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet
Projects
None yet
Development

No branches or pull requests

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy