Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@
from airflow.providers.amazon.aws.utils.connection_wrapper import AwsConnectionWrapper
from airflow.providers.amazon.aws.utils.identifiers import generate_uuid
from airflow.providers.amazon.aws.utils.suppress import return_on_error
from airflow.providers.common.compat.version_compat import AIRFLOW_V_3_0_PLUS
from airflow.providers_manager import ProvidersManager
from airflow.utils.helpers import exactly_one
from airflow.utils.log.logging_mixin import LoggingMixin

BaseAwsConnection = TypeVar("BaseAwsConnection", bound=Union[boto3.client, boto3.resource])

if AIRFLOW_V_3_0_PLUS:
from airflow.sdk.exceptions import AirflowRuntimeError

if TYPE_CHECKING:
from aiobotocore.session import AioSession
from botocore.client import ClientMeta
Expand Down Expand Up @@ -603,12 +607,24 @@ def conn_config(self) -> AwsConnectionWrapper:
"""Get the Airflow Connection object and wrap it in helper (cached)."""
connection = None
if self.aws_conn_id:
possible_exceptions: tuple[type[Exception], ...]

if AIRFLOW_V_3_0_PLUS:
possible_exceptions = (AirflowNotFoundException, AirflowRuntimeError)
else:
possible_exceptions = (AirflowNotFoundException,)

try:
connection = self.get_connection(self.aws_conn_id)
except AirflowNotFoundException:
self.log.warning(
"Unable to find AWS Connection ID '%s', switching to empty.", self.aws_conn_id
)
except possible_exceptions as e:
if isinstance(
e, AirflowNotFoundException
) or f"Connection with ID {self.aws_conn_id} not found" in str(e):
self.log.warning(
"Unable to find AWS Connection ID '%s', switching to empty.", self.aws_conn_id
)
else:
raise

return AwsConnectionWrapper(
conn=connection, region_name=self._region_name, botocore_config=self._config, verify=self._verify
Expand Down