1 import boto3 2 import configparser 3 import json 4 5 class configManager: 6 def __init__(self, config_file_path='../helper/config.ini'): 7 self.config = configparser.ConfigParser() 8 self.config.read(config_file_path) 9 10 11 def get_credentials(self, secret_name, mode='secrets'): 12 secrets_client = boto3.client("secretsmanager", region_name="us-east-1") 13 secret = secrets_client.get_secret_value(SecretId=secret_name) 14 return json.loads(secret['SecretString']) 15 16 def get_config(self, source): 17 transformation = self.config[source] 18 return dict(transformation) 19 20 def get_details(self, source, get_creds=True): 21 d =self.get_config( source) 22 if get_creds: 23 d['creds'] = self.get_credentials( d['source_secret'] ) 24 return d