This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 816c70ce15c Revert "Fix fetch_access_token_for_cluster in EKS hook"
(#45526)
816c70ce15c is described below
commit 816c70ce15c4caeae0fb2024bb6a1bc012e6101a
Author: Vincent <[email protected]>
AuthorDate: Thu Jan 9 17:09:48 2025 -0500
Revert "Fix fetch_access_token_for_cluster in EKS hook" (#45526)
* Revert "Fix the way to get STS endpoint in EKS hook (#45520)"
This reverts commit 103df61bde6e98de2466f42e76b4ac3bcc4ab8b5.
* Revert "Fix `fetch_access_token_for_cluster` in EKS hook (#45469)"
This reverts commit dc3111aa8d2358172de3afe7d717fd03cca59455.
---
providers/src/airflow/providers/amazon/aws/hooks/eks.py | 5 +++--
providers/tests/amazon/aws/hooks/test_eks.py | 4 +---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/providers/src/airflow/providers/amazon/aws/hooks/eks.py
b/providers/src/airflow/providers/amazon/aws/hooks/eks.py
index 4e8c0ca7ad6..2b31f5afb66 100644
--- a/providers/src/airflow/providers/amazon/aws/hooks/eks.py
+++ b/providers/src/airflow/providers/amazon/aws/hooks/eks.py
@@ -32,7 +32,6 @@ from botocore.exceptions import ClientError
from botocore.signers import RequestSigner
from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
-from airflow.providers.amazon.aws.hooks.sts import StsHook
from airflow.utils import yaml
from airflow.utils.json import AirflowJsonEncoder
@@ -613,7 +612,9 @@ class EksHook(AwsBaseHook):
def fetch_access_token_for_cluster(self, eks_cluster_name: str) -> str:
session = self.get_session()
service_id = self.conn.meta.service_model.service_id
- sts_url =
f"{StsHook().conn_client_meta.endpoint_url}/?Action=GetCallerIdentity&Version=2011-06-15"
+ sts_url = (
+
f"https://sts.{session.region_name}.amazonaws.com/?Action=GetCallerIdentity&Version=2011-06-15"
+ )
signer = RequestSigner(
service_id=service_id,
diff --git a/providers/tests/amazon/aws/hooks/test_eks.py
b/providers/tests/amazon/aws/hooks/test_eks.py
index 10a93790ac6..cf3638d30d3 100644
--- a/providers/tests/amazon/aws/hooks/test_eks.py
+++ b/providers/tests/amazon/aws/hooks/test_eks.py
@@ -1283,13 +1283,11 @@ class TestEksHook:
}
@mock.patch("airflow.providers.amazon.aws.hooks.eks.RequestSigner")
- @mock.patch("airflow.providers.amazon.aws.hooks.eks.StsHook")
@mock.patch("airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook.conn")
@mock.patch("airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook.get_session")
- def test_fetch_access_token_for_cluster(self, mock_get_session, mock_conn,
mock_sts_hook, mock_signer):
+ def test_fetch_access_token_for_cluster(self, mock_get_session, mock_conn,
mock_signer):
mock_signer.return_value.generate_presigned_url.return_value =
"http://example.com"
mock_get_session.return_value.region_name = "us-east-1"
- mock_sts_hook.return_value.conn_client_meta.endpoint_url =
"https://sts.us-east-1.amazonaws.com"
hook = EksHook()
token =
hook.fetch_access_token_for_cluster(eks_cluster_name="test-cluster")
mock_signer.assert_called_once_with(