Taragolis commented on code in PR #28545:
URL: https://github.com/apache/airflow/pull/28545#discussion_r1056694827
##########
airflow/providers/amazon/aws/hooks/base_aws.py:
##########
@@ -754,7 +754,9 @@ def test_connection(self):
"""
try:
session = self.get_session()
- conn_info = session.client("sts").get_caller_identity()
+ conn_info = session.client(
+ "sts", endpoint_url=self.conn_config.endpoint_url
+ ).get_caller_identity()
Review Comment:
I worked on the same feature, my implementation something like that for
`AwsConnectionWrapper` method
```python
def get_service_endpoint(self, service_name: str, *, sts_use_default:
bool = False) -> str | None:
"""
Return endpoint_url for specific service.
:param service_name: The name of a service, e.g. 's3' or 'ec2'.
:param sts_use_default: Is associate default endpoint url from
config with sts service.
For historical reason AwsBaseHook never use endpoint url from
Connection because this could break some connections, e.g.
obtained by Assume Role.
"""
if not self._endpoint_url:
return None
try:
return self._endpoint_url[service_name]
except KeyError:
default = self._endpoint_url.get("_default")
if service_name != "sts" or sts_use_default:
return default
elif default:
warnings.warn(
"Default endpoint URL disabled for 'sts' service, please
set it explicit.",
UserWarning,
stacklevel=3,
)
return None
```
And some extending in connection:
1. Allow set `endpoint_url` as dictionary
2. If `endpoint_url` set as non empty string then convert it to
`{'_default': endpoint_url}`
This just a sample, I do not have strong opinion about final implementation.
My only point about the current limitation of `endpoint_url` and why we do
not provide it into STS client
--
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]