---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "mongodb_users Data Source - terraform-provider-mongodb-driver"
subcategory: ""
description: |-
  MongoDB user listing data source
---

# mongodb_users (Data Source)

MongoDB user listing data source

## Example Usage

```terraform
// Search all users in all databases
data "mongodb_users" "example" {
}

// Search all users in specific databases
data "mongodb_users" "example" {
  db = "my-db"
}

// Search all users with custom filter
data "mongodb_users" "example" {
  filter = {
    "customData.my-custom-field" = "my-custom-value"
  }
}

// With custom timeouts
data "mongodb_users" "example" {
  db = "my-db"

  // Timeouts default to 30 seconds
  timeouts = {
    read = "5s" // 5 seconds
  }
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `db` (String) Which database to list users from. If `null`, then will list users in all databases.

  MongoDB has some restrictions on database names. Such as:

  - Cannot contain any of the following characters (we're following Windows limits): `/\. "$*<>:|?`
  - Cannot be empty.
  - Cannot be longer than 64 characters.

  See documentation:

  - <https://www.mongodb.com/docs/v6.0/reference/limits/#naming-restrictions>
- `filter` (Map of String) Additional filters to apply.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `users` (Attributes List) List of users fetched from MongoDB (see [below for nested schema](#nestedatt--users))

<a id="nestedatt--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).


<a id="nestedatt--users"></a>
### Nested Schema for `users`

Read-Only:

- `custom_data` (Map of String) Any custom data for this user. Map of string key and values of arbitrary values.
- `db` (String) Database this MongoDB user belongs to.
- `id` (String) User unique ID in MongoDB. Is composed from the `db` and `user` fields.
- `mechanisms` (List of String) Authentication mechanisms this user can use.
- `roles` (Attributes List) Roles this user belongs to. (see [below for nested schema](#nestedatt--users--roles))
- `user` (String) Username for this MongoDB user.

<a id="nestedatt--users--roles"></a>
### Nested Schema for `users.roles`

Read-Only:

- `db` (String) Database this role belongs to.
- `role` (String) Role name
