Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users created in wrong db #37

Open
bsamsom opened this issue Apr 28, 2023 · 2 comments
Open

Users created in wrong db #37

bsamsom opened this issue Apr 28, 2023 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation investigating Testing This Labels refers to (tests in progress)

Comments

@bsamsom
Copy link

bsamsom commented Apr 28, 2023

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.

@ITMonta ITMonta added the documentation Improvements or additions to documentation label Apr 29, 2023
@ITMonta
Copy link
Contributor

ITMonta commented Apr 29, 2023

Hello @bsamsom Thank you for your feed back can you specify which version of the provider you are using ?

@bsamsom
Copy link
Author

bsamsom commented Apr 29, 2023

I'm using version 0.1.7 of the provider with Document DB 5.0

@ITMonta ITMonta added the Testing This Labels refers to (tests in progress) label Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation investigating Testing This Labels refers to (tests in progress)
Projects
None yet
Development

No branches or pull requests

3 participants