pgagnon commented on code in PR #29623: URL: https://github.com/apache/airflow/pull/29623#discussion_r1112140747
########## airflow/providers/amazon/aws/hooks/base_aws.py: ########## @@ -311,20 +311,32 @@ def _get_web_identity_credential_fetcher( ) -> botocore.credentials.AssumeRoleWithWebIdentityCredentialFetcher: base_session = self.basic_session._session or botocore.session.get_session() client_creator = base_session.create_client - federation = self.extra_config.get("assume_role_with_web_identity_federation") - if federation == "google": - web_identity_token_loader = self._get_google_identity_token_loader() - else: - raise AirflowException( - f'Unsupported federation: {federation}. Currently "google" only are supported.' - ) + federation = str(self.extra_config.get("assume_role_with_web_identity_federation")) + + web_identity_token_loader = { + "file": self._get_file_token_loader, + "google": self._get_google_identity_token_loader, + }.get(federation, lambda: None)() + + if not web_identity_token_loader: Review Comment: It will because the callable is called right before assignment: ``` $ python Python 3.9.7 (default, Dec 5 2021, 13:21:59) [Clang 12.0.5 (clang-1205.0.22.9)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def _get_file_token_loader(): ... return "file" ... >>> def _get_google_identity_token_loader(): ... return "google" ... >>> federation = "test" >>> >>> web_identity_token_loader = { ... "file": _get_file_token_loader, ... "google": _get_google_identity_token_loader, ... }.get(federation, lambda: None)() >>> >>> print("hit" if not web_identity_token_loader else "not hit") hit ``` -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org