Beispiel #1
0
def read_properties_file(fn):
    retDict = {}
    p = Properties()
    if os.path.exists(fn):
        with open(fn, 'rb') as f:
            p.load(f, 'utf-8')

        for k in p.keys():
            retDict[str(k)] = str(p[k].data)

    return retDict
Beispiel #2
0
def deploy_configuration(props: Properties, nmspce: str):
    # add prefix slash if necessary
    nmspce = nmspce if nmspce[0] == '/' else '/' + nmspce

    ssm = boto3.client('ssm', config=Config(retries={'max_attempts': 5}))

    try:

        for k in props.keys():
            # create complete path and upload
            param_path = f'{nmspce}/{k}'

            response = ssm.put_parameter(Name=param_path,
                                         Value=props[k].data,
                                         Type='String',
                                         Overwrite=True)

            version = response['Version']
            logger.debug(
                f'Parameter {param_path} version {version} upload complete')

    except Exception as e:
        raise e