1717
1818import boto3
1919from dotenv import load_dotenv
20- from google .auth .aws import Credentials as AwsCredentials
2120from google .auth .aws import AwsSecurityCredentials , AwsSecurityCredentialsSupplier
21+ from google .auth .aws import Credentials as AwsCredentials
2222from google .auth .exceptions import GoogleAuthError
2323from google .auth .transport .requests import AuthorizedSession
2424
2828class CustomAwsSupplier (AwsSecurityCredentialsSupplier ):
2929 """Custom AWS Security Credentials Supplier."""
3030
31- def __init__ (self ):
31+ def __init__ (self ) -> None :
3232 """Initializes the Boto3 session, prioritizing environment variables for region."""
3333 # Explicitly read the region from the environment first. This ensures that
3434 # a value from a .env file is picked up reliably for local testing.
@@ -39,7 +39,7 @@ def __init__(self):
3939 self ._cached_region = None
4040 print (f"[INFO] CustomAwsSupplier initialized. Region from env: { region } " )
4141
42- def get_aws_region (self , context , request ) -> str :
42+ def get_aws_region (self , context : object , request : object ) -> str :
4343 """Returns the AWS region using Boto3's default provider chain."""
4444 if self ._cached_region :
4545 return self ._cached_region
@@ -55,7 +55,7 @@ def get_aws_region(self, context, request) -> str:
5555 print (f"[INFO] Boto3 resolved AWS Region: { self ._cached_region } " )
5656 return self ._cached_region
5757
58- def get_aws_security_credentials (self , context , request = None ) -> AwsSecurityCredentials :
58+ def get_aws_security_credentials (self , context : object , request : object = None ) -> AwsSecurityCredentials :
5959 """Retrieves AWS security credentials using Boto3's default provider chain."""
6060 aws_credentials = self .session .get_credentials ()
6161 if not aws_credentials :
@@ -71,7 +71,7 @@ def get_aws_security_credentials(self, context, request=None) -> AwsSecurityCred
7171 )
7272
7373
74- def main ():
74+ def main () -> None :
7575 """Main function to demonstrate the custom AWS supplier."""
7676 print ("--- Starting Script ---" )
7777
0 commit comments