Get all IAM user details. Produces results that can be used to create an
    sls file.

    .. versionadded:: 2016.3.0

    CLI Example:

        salt-call boto_iam.export_users --out=txt | sed "s/local: //" > iam_users.sls

def export_users(path_prefix='/', region=None, key=None, keyid=None,
                 profile=None):
    '''
    Get all IAM user details. Produces results that can be used to create an
    sls file.

    .. versionadded:: 2016.3.0

    CLI Example:

        salt-call boto_iam.export_users --out=txt | sed "s/local: //" > iam_users.sls
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    if not conn:
        return None
    results = odict.OrderedDict()
    users = get_all_users(path_prefix, region, key, keyid, profile)
    for user in users:
        name = user.user_name
        _policies = conn.get_all_user_policies(name, max_items=100)
        _policies = _policies.list_user_policies_response.list_user_policies_result.policy_names
        policies = {}
        for policy_name in _policies:
            _policy = conn.get_user_policy(name, policy_name)
            _policy = salt.utils.json.loads(_unquote(
                    _policy.get_user_policy_response.get_user_policy_result.policy_document
            ))
            policies[policy_name] = _policy
        user_sls = []
        user_sls.append({"name": name})
        user_sls.append({"policies": policies})
        user_sls.append({"path": user.path})
        results["manage user " + name] = {"boto_iam.user_present": user_sls}
    return __utils__['yaml.safe_dump'](
        results,
        default_flow_style=False,
        indent=2)