You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more information refer to the [product documentation](https://www.scaleway.com/en/docs/managed-mongodb-databases/).
10
+
11
+
## Example Usage
12
+
13
+
### Basic
14
+
15
+
```terraform
16
+
resource "scaleway_mongodb_instance" "main" {
17
+
name = "test-mongodb-user"
18
+
version = "7.0.12"
19
+
node_type = "MGDB-PLAY2-NANO"
20
+
node_number = 1
21
+
user_name = "initial_user"
22
+
password = "initial_password123"
23
+
volume_size_in_gb = 5
24
+
}
25
+
26
+
resource "scaleway_mongodb_user" "main" {
27
+
instance_id = scaleway_mongodb_instance.main.id
28
+
name = "my_user"
29
+
password = "my_password123"
30
+
31
+
roles {
32
+
role = "read_write"
33
+
database_name = "my_database"
34
+
}
35
+
}
36
+
```
37
+
38
+
### With Multiple Users
39
+
40
+
```terraform
41
+
resource "scaleway_mongodb_instance" "main" {
42
+
name = "test-mongodb-multi-user"
43
+
version = "7.0.12"
44
+
node_type = "MGDB-PLAY2-NANO"
45
+
node_number = 1
46
+
user_name = "admin_user"
47
+
password = "admin_password123"
48
+
volume_size_in_gb = 5
49
+
}
50
+
51
+
resource "scaleway_mongodb_user" "app_user" {
52
+
instance_id = scaleway_mongodb_instance.main.id
53
+
name = "app_user"
54
+
password = "app_password123"
55
+
56
+
roles {
57
+
role = "read_write"
58
+
database_name = "app_database"
59
+
}
60
+
61
+
roles {
62
+
role = "read"
63
+
database_name = "logs_database"
64
+
}
65
+
}
66
+
67
+
resource "scaleway_mongodb_user" "admin_user" {
68
+
instance_id = scaleway_mongodb_instance.main.id
69
+
name = "admin_user"
70
+
password = "admin_password123"
71
+
72
+
roles {
73
+
role = "db_admin"
74
+
database_name = "admin"
75
+
}
76
+
77
+
roles {
78
+
role = "read"
79
+
any_database = true
80
+
}
81
+
}
82
+
```
83
+
84
+
## Argument Reference
85
+
86
+
The following arguments are supported:
87
+
88
+
-`instance_id` - (Required) The ID of the MongoDB® instance.
89
+
90
+
-`name` - (Required) The name of the MongoDB® user.
91
+
92
+
-`password` - (Required) The password of the MongoDB® user.
93
+
94
+
-`roles` - (Optional) List of roles assigned to the user. Each role block supports:
95
+
-`role` - (Required) The role name. Valid values are `read`, `read_write`, `db_admin`, `sync`.
96
+
-`database_name` - (Optional) The database name for the role. Cannot be used with `any_database`.
97
+
-`any_database` - (Optional) Apply the role to all databases. Cannot be used with `database_name`.
98
+
99
+
-`region` - (Defaults to [provider](../index.md#region)`region`) The [region](../guides/regions_and_zones.md#regions) in which the MongoDB® user should be created.
100
+
101
+
## Attributes Reference
102
+
103
+
In addition to all arguments above, the following attributes are exported:
104
+
105
+
-`id` - The ID of the MongoDB® user.
106
+
107
+
-`roles` - The list of roles assigned to the user.
108
+
109
+
## Import
110
+
111
+
MongoDB® users can be imported using the `{region}/{instance_id}/{name}`, e.g.
0 commit comments