Skip to content

Commit

Permalink
Revert "Fix fetch_access_token_for_cluster in EKS hook" (apache#45526)
Browse files Browse the repository at this point in the history
* Revert "Fix the way to get STS endpoint in EKS hook (apache#45520)"

This reverts commit 103df61.

* Revert "Fix `fetch_access_token_for_cluster` in EKS hook (apache#45469)"

This reverts commit dc3111a.
  • Loading branch information
vincbeck authored and HariGS-DB committed Jan 16, 2025
1 parent 92f157c commit a8fb1e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions providers/src/airflow/providers/amazon/aws/hooks/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
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

Expand Down Expand Up @@ -613,7 +612,9 @@ def generate_config_file(
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,
Expand Down
4 changes: 1 addition & 3 deletions providers/tests/amazon/aws/hooks/test_eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,13 +1283,11 @@ def test_generate_config_file(self, mock_conn, aws_conn_id, region_name, expecte
}

@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(
Expand Down

0 comments on commit a8fb1e3

Please sign in to comment.