terraform-provider-mongodb
terraform-provider-mongodb copied to clipboard
Users created in wrong db
When looking at the examples:
There is an example of setting up the provider on the admin
db:
https://github.com/Kaginari/terraform-provider-mongodb/blob/main/examples/main.tf#L18
but creating users under the exemple
db
https://github.com/Kaginari/terraform-provider-mongodb/blob/main/examples/main.tf#L68
but when trying to do something similar,
provider "mongodb" {
...
auth_database = "admin"
}
resource "mongodb_db_user" "users" {
auth_database = example
name = test-user
password = test-password
role {
role = "readWrite"
db = example
}
}
and connecing to the db and running db.getUsers()
{
_id: 'test-user,
user: 'test-user",
db: 'admin',
roles: [ { db: 'example', role: 'readWrite' } ]
},
The db where the user is created is the admin
db, instead of the expected example
db
basically it seems to be missing a use example
before the creation of the users.
best guess would be theres some confusion in the code of using the same name auth_database
in both the provider and in the resource when they can be differnt values.