def var_replace(vars, value):
    """Replace all instances of ${x} in value with the value of vars['x']."""
    if value is None:
        return value

    for var, rep in vars.items():
        if isinstance(rep, str):
            value = value.replace(f"${{{var}}}", rep)

    return value