diff --git a/prowler/providers/aws/lib/credentials/credentials.py b/prowler/providers/aws/lib/credentials/credentials.py index 8d7984d855..6e8e7967f0 100644 --- a/prowler/providers/aws/lib/credentials/credentials.py +++ b/prowler/providers/aws/lib/credentials/credentials.py @@ -69,6 +69,9 @@ Caller Identity ARN: {Fore.YELLOW}[{audit_info.audited_identity_arn}]{Style.RESE def create_sts_session( session: session.Session, aws_region: str ) -> session.Session.client: - return session.client( - "sts", aws_region, endpoint_url=f"https://sts.{aws_region}.amazonaws.com" + sts_endpoint_url = ( + f"https://sts.{aws_region}.amazonaws.com" + if "cn-" not in aws_region + else f"https://sts.{aws_region}.amazonaws.com.cn" ) + return session.client("sts", aws_region, endpoint_url=sts_endpoint_url) diff --git a/tests/providers/aws/lib/credentials/credentials_test.py b/tests/providers/aws/lib/credentials/credentials_test.py index 6397cc3d64..c230e5f66e 100644 --- a/tests/providers/aws/lib/credentials/credentials_test.py +++ b/tests/providers/aws/lib/credentials/credentials_test.py @@ -507,4 +507,4 @@ class Test_AWS_Credentials: sts_client = create_sts_session(session, aws_region) assert sts_client._endpoint._endpoint_prefix == "sts" - assert sts_client._endpoint.host == f"https://sts.{aws_region}.amazonaws.com" + assert sts_client._endpoint.host == f"https://sts.{aws_region}.amazonaws.com.cn"