-
Notifications
You must be signed in to change notification settings - Fork 191
fix: How do I create Organization API Key with Organization Billing Admin permission and Project Read Only for projects #1369
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
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
122af77
INTMDB-898: fixing
andreaangiolillo 301c978
Merge remote-tracking branch 'origin/master' into INTMDB-898_3
andreaangiolillo 28bdbfc
fixed bug
andreaangiolillo 65c49f2
added acceptance tests
andreaangiolillo 1be6d59
Updated doc
andreaangiolillo f2e0820
Update acceptance-tests.yml
andreaangiolillo 1bf555b
Update website/docs/r/project_api_key.html.markdown
andreaangiolillo 0a1ad79
Addressed PR comments
andreaangiolillo 038b90e
Merge remote-tracking branch 'origin/master' into INTMDB-898_3
andreaangiolillo b728902
Merge branch 'INTMDB-898_3' of github.com:mongodb/terraform-provider-…
andreaangiolillo 955f875
Addressed PR comments
andreaangiolillo 56774ae
Addressed PR comments
andreaangiolillo 1105890
Merge remote-tracking branch 'origin/master' into INTMDB-898_3
andreaangiolillo fec47fa
Addressed PR comments
andreaangiolillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a risk in having this global variable being used in separate operations? Set during create, and then used during read and delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I don't this is an issue but I renamed the var to make it more specific to the project API key resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only doubt is that this might work during acceptance tests as the test framework maintains one plugin gRPC server for the duration of each test case, while in normal Terraform operations the plugin server starts and stops (reference).
Approving the PR, I would just try a local build to be sure org roles are supported with no issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misread this comment the first time. The reason why I defined this as a global var was to use it in the create and read operations as I need to know if the user has provided any ORG roles in the config:
The main reason for this is that the CREATE endpoint creates an org API key with
ORG_READ_ONLY
role if the user did not provide any ORG_ROLES as input. In this scenario, the READ will return theORG_READ_ONLY
role (in addition to theGROUP_*
roles) even if the user provided only GROUP rolesIn this case, the READ operation is called as last step of the CREATE so we do not hit this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the changes with the Terraform configurations provided in the description of the PR (
ORG_READ_ONLY
is there) and in this comment #1369 (comment). Let me know if I should test locally another scenarioThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with the following example:
terraform apply
creates the api key successfully.terraform plan
outputs incorrect diff showing that "ORG_READ_ONLY" will be added.I believe the
projectAPIKeyOrgRoleProvided
is not preserving its value during the create and following read operation done interraform plan
, so it filters out the org role.Let me know if you are able to reproduce the same, it is indeed an edge case but might be worth addressing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not able to reproduce the issue
apply
plan:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to reproduce the issue: the reason why it did not "fail" during the plan is that I was using the provider in debug mode. Thanks for the discussion here. I will see if I find a way around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I have not found a way to allow the use of
ORG_READ_ONLY
since it is automatically added when ORG roles are not provided. As a result, I updated the logic to now allow theORG_READ_ONLY
for project assignments and update the documentation to explain why. This should not be a breaking change since customers were not able to use this resource with org roles.