def flatten_parameters()

in lambda_function_code/dashboard_connection.py [0:0]


def flatten_parameters(parameters):
    """This takes a hierarchy of parameters as obtained from the SSM parameter store,
    and flattens it in simple key/value pairs {"AccountID1": "ProjectName1", ...}

    Args:
        parameters (dict): the parameters obtained from the SSM

    Returns:
        [dict]: a flat dictionary with account ids and project names
    """

    accounts = {}

    for p in parameters:
        p_account = p["Value"]
        accounts[p_account] = {}
        # separator for values is ;
        p_name = p["Name"].split("/")[2]
        accounts[p_account] = p_name

    return accounts