vincbeck commented on code in PR #77163:
URL: https://github.com/apache/airflow/pull/77163#discussion_r4643805368


##########
providers/amazon/src/airflow/providers/amazon/aws/hooks/eks.py:
##########
@@ -669,11 +669,10 @@ def generate_config_file(
         cluster_cert = cluster["cluster"]["certificateAuthority"]["data"]
         cluster_ep = cluster["cluster"]["endpoint"]
 
-        os.environ["AWS_STS_REGIONAL_ENDPOINTS"] = "regional"
-        try:
-            sts_url = 
f"{StsHook(region_name=session.region_name).conn_client_meta.endpoint_url}/?Action=GetCallerIdentity&Version=2011-06-15"
-        finally:
-            del os.environ["AWS_STS_REGIONAL_ENDPOINTS"]
+        # EKS needs the regional STS endpoint, which botocore uses by default 
since 1.40. Do not set
+        # AWS_STS_REGIONAL_ENDPOINTS here: the environment is shared by every 
trigger in the triggerer.
+        sts_endpoint = 
StsHook(region_name=session.region_name).conn_client_meta.endpoint_url

Review Comment:
   Should we pass `aws_conn_id=self.aws_conn_id` here, like `AwsEksExecutor` 
does? Today `StsHook` falls back to `aws_default`, so it ignores the endpoint 
settings of the connection the user configured.



##########
providers/amazon/tests/unit/amazon/aws/hooks/test_eks.py:
##########
@@ -1359,6 +1361,28 @@ def test_generate_config_file(self, mock_conn, 
aws_conn_id, region_name, expecte
             if expected_region_args:
                 assert expected_region_args in command_arg
 
+    @mock.patch.object(EksHook, "conn", new_callable=PropertyMock)
+    def test_generate_config_file_keeps_existing_sts_regional_endpoints(self, 
mock_conn, monkeypatch):
+        """The hook follows the botocore STS endpoint setting and leaves the 
process environment alone."""
+        monkeypatch.setenv("AWS_STS_REGIONAL_ENDPOINTS", "legacy")
+        mock_conn.return_value.describe_cluster.return_value = {
+            "cluster": {"certificateAuthority": {"data": "test-cert"}, 
"endpoint": "test-endpoint"}
+        }
+        hook = EksHook(aws_conn_id=None, region_name="us-west-2")
+
+        with mock.patch.object(StsHook, "get_connection", return_value=None):

Review Comment:
   Not a big deal but we usually use the decorator



-- 
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