vandonr-amz commented on code in PR #32733:
URL: https://github.com/apache/airflow/pull/32733#discussion_r1270880821


##########
airflow/providers/amazon/aws/hooks/base_aws.py:
##########
@@ -197,22 +197,41 @@ def _create_basic_session(self, session_kwargs: dict[str, 
Any]) -> boto3.session
     def _create_session_with_assume_role(
         self, session_kwargs: dict[str, Any], deferrable: bool = False
     ) -> boto3.session.Session:
-
         if self.conn.assume_role_method == "assume_role_with_web_identity":
             # Deferred credentials have no initial credentials
             credential_fetcher = self._get_web_identity_credential_fetcher()
-            credentials = botocore.credentials.DeferredRefreshableCredentials(
-                method="assume-role-with-web-identity",
-                refresh_using=credential_fetcher.fetch_credentials,
-                time_fetcher=lambda: datetime.datetime.now(tz=tzlocal()),
-            )
+
+            if deferrable:
+                from aiobotocore.credentials import 
AioDeferredRefreshableCredentials
+
+                credentials = AioDeferredRefreshableCredentials(
+                    method="assume-role-with-web-identity",
+                    refresh_using=credential_fetcher.fetch_credentials,
+                    time_fetcher=lambda: datetime.datetime.now(tz=tzlocal()),

Review Comment:
   nit: you could pack those parameters in a `dict` and pass it as `**params` 
to avoid duplication.
   Same for the `else` case below.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to