import json from typing import Any, Dict from aws_testing_utils.logger import log import boto3 from botocore.exceptions import NoCredentialsError, PartialCredentialsError from tests import config class SecretsManager: def __init__(self) -> None: self.client = boto3.client('secretsmanager', region_name=config.AWS_REGION) def get_db_credentials( self, secret_name: str = config.CYPRESS_SECRET_NAME ) -> Dict[str, Dict[str, Any]]: result = {} try: response = self.client.get_secret_value(SecretId=secret_name) secret = response['SecretString'] secret_data = json.loads(secret) result = secret_data except (NoCredentialsError, PartialCredentialsError) as e: log.info(f'Error fetching credentials: {e}') result = {} return result