Skip to content

Cannot import mongodbatlas_database_user if username contains a hyphen #234

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

Closed
MontgomeryWatts opened this issue May 25, 2020 · 6 comments
Closed

Comments

@MontgomeryWatts
Copy link

I was trying to import a mongodbatlas_database_user where the username is lambda-producer. I used a hyphen in the name to be in line with the example usage but when running terraform import mongodbatlas_database_user.producer_user <PROJECT-ID>-lambda-producer-admin it's clear from the output that it is interpreted as the username being lambda and the auth_database_name being producer-admin. The import section shows an example with a username that contains an underscore.

Since the documentation claims that syntax works but doesn't, could the docs be changed to show usernames with underscores, or is this broken functionality?

@themantissa
Copy link
Collaborator

themantissa commented May 26, 2020

@MontgomeryWatts it's a known bug, reported and corrected and should be included in our next version release but already available in our master branch. See https://github.com/terraform-providers/terraform-provider-mongodbatlas/issues/179 and https://github.com/terraform-providers/terraform-provider-mongodbatlas/pull/214

Thanks!
Melissa

@themantissa
Copy link
Collaborator

themantissa commented Jun 27, 2020 via email

@enm10k
Copy link

enm10k commented Sep 16, 2020

@themantissa

Apparently I still have the same issue, although I'm using v0.6.4.

$ terraform init -v
Terraform v0.12.24
+ provider.mongodbatlas v0.6.4

Your version of Terraform is out of date! The latest version
is 0.13.2. You can update by downloading from https://www.terraform.io/downloads.html

See https://github.com/terraform-providers/terraform-provider-mongodbatlas/issues/179 and https://github.com/terraform-providers/terraform-provider-mongodbatlas/pull/214

I want to check the issue and the PR but it's not reachable anymore.
Could you let me know where I can access the information?

@themantissa
Copy link
Collaborator

@enm10k apologies, as part of the Terraform .13 provider changes we had to move back to a MongoDB repo in Github. The new links are:
See #179 and #214

@enm10k
Copy link

enm10k commented Sep 17, 2020

Thanks for you quick response!

https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/database_user#import

Import
Database users can be imported using project ID and username, in the format project_id-username-auth_database_name, e.g.

After reviewing the information, I realized I misunderstood about auth_database_name.
I specified the actual database name with a hyphen and got an error like the following.

$ terraform import mongodbatlas_database_user.a_database_user <project_id>-user-name-database-name
mongodbatlas_database_user.a_database_user: Importing from ID "<project_id>-user-name-database-name"...

Error: import format error: to import a Database User, use the format {project_id}-{username}-{auth_database_name}

terraform import mongodbatlas_database_user.a_database_user '<project_id>-user-name-$external' worked for me.
Thanks again!

@themantissa
Copy link
Collaborator

@enm10k glad to hear you are good to go! Let us know if anything else comes up. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants