Skip to content

Path escape import id of database user #373

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

Merged

Conversation

KeisukeYamashita
Copy link
Contributor

@KeisukeYamashita KeisukeYamashita commented Jan 2, 2021

Description

I path escaped the user input id for mongodbatlas_database_user.
When I tried to import DB user for AWS role type user, I ran this command.

$ terraform import mongodbatlas_database_user.my_db_user 'MASKED_ATLAS_PROJECT_ID-arn:aws:iam::MASKED_AWS_PROJECT_ID:role/my-role-$external'

But got this error.

Error: couldn't import user(arn:aws:iam::MASKED_AWS_PROJECT_ID:role:role/my-role) in project(MASKED_ATLAS_PROJECT_ID), error: GET https://cloud.mongodb.com/api/atlas/v1.0/groups/MASKED_ATLAS_PROJECT_ID/databaseUsers/$external/arn:aws:iam::MASKED_ATLAS_PROJECT_ID:role/my-role: 404 (request "Not Found") Cannot find resource /api/atlas/v1.0/groups/MASKED_ATLAS_PROJECT_ID/databaseUsers/$external/arn:aws:iam::MASKED_ATLAS_PROJECT_ID:role:role/my-role.

But if I run the command below (with / path escaped), it's okay:

$ terraform import mongodbatlas_database_user.my_db_user 'MASKED_ATLAS_PROJECT_ID-arn:aws:iam::MASKED_AWS_PROJECT_ID:role%2Fmy-role-$external'

I want the script to handle the space, not developers so that developers can import much easier.

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the Terraform contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirments
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KeisukeYamashita good catch! @leofigy @coderGo93 or @marinsalinas can one of you review as well? Seems we missed the escape for import but got it for read update delete. Thanks!

Copy link
Contributor

@marinsalinas marinsalinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!! LGTM!

@themantissa
Copy link
Collaborator

@coderGo93 can you merge this and ensure the tests run/pass so we can make sure the import doesn't have any issues?

@coderGo93 coderGo93 merged commit 1fa06b5 into mongodb:master Jan 7, 2021
@KeisukeYamashita KeisukeYamashita deleted the path-escape-database-user-import branch January 8, 2021 02:25
@KeisukeYamashita
Copy link
Contributor Author

Thank you all for your reviews 👍

@themantissa Do you have any plans for when it will this change will be released? I want this PR change and this change to be released because I use this resource and it's preventing me to update it.

@themantissa
Copy link
Collaborator

@KeisukeYamashita eta is mid this month so should be soon.

@KeisukeYamashita
Copy link
Contributor Author

Got it. Thank you for your reply👍

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

Successfully merging this pull request may close these issues.

4 participants