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

fix: adjust root project_id attribute in mongdbatlas_project_api_key resource to optional #1664

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

AgustinBettati
Copy link
Member

Description

Link to any related issue(s): INTMDB-1296

Making root project_id attribute in mongdbatlas_project_api_key optional enables users to unassign the root project from the created API Key without having to delete the resource all together. More details in the referenced ticket.

Type of change:

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

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

@github-actions github-actions bot added the bug label Nov 23, 2023
Comment on lines 272 to 273
_, roleOk := d.GetOk("role_names")
if !roleOk {
Copy link
Member Author

Choose a reason for hiding this comment

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

legacy check, role_names no longer exists at root level.

@@ -16,29 +16,32 @@ description: |-

## Example Usage

### Using org_id attribute to query
Copy link
Member Author

Choose a reason for hiding this comment

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

no changes in data source, just doc fixes I found

@@ -17,29 +17,25 @@ description: |-
## Example Usage

```terraform
resource "mongodbatlas_project_api_key" "test" {
Copy link
Member Author

Choose a reason for hiding this comment

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

no changes in data source, just doc fixes I found

}

// creates api key using project id of first defined project assignment
firstAssignment := projectAssignmentList[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this new behaviour be documented? is it a breaking change? What happens with project_id when it is actually defined? from this code it seems like it won't be used aynmore

Copy link
Member Author

Choose a reason for hiding this comment

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

So this is more of an implementation detail: one project id is used for the creation of the api key, and then remaining projects assignments are assigned to the new api key. The previous implementation was essentially the same, only instead of taking the first element for the project assignment list it would grab the project which was defined in root project_id for the creation of the api key. From a users standpoint it is the same.

What happens with project_id when it is actually defined? from this code it seems like it won't be used anymore

This is correct, it is no longer used. From docs changes and deprecation warning users will be aware this attribute is no longer being used (https://github.com/mongodb/terraform-provider-mongodbatlas/pull/1665/files#diff-31571e18c14ed5632e87c050342b195d9cbc5092b465b08abfb8b1dcf87d37bdL49)

Base automatically changed from INTMDB-1296-required-proj-assignment to master November 24, 2023 08:37
Copy link
Contributor

Code Coverage

Package Line Rate Health
github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion 31%
github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate 68%
github.com/mongodb/terraform-provider-mongodbatlas/internal/provider 5%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster 3%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/atlasuser 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cluster 1%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/databaseuser 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/encryptionatrest 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/project 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectipaccesslist 0%
github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment 23%
github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc 6%
github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas 2%
Summary 3% (315 / 10692)

@AgustinBettati
Copy link
Member Author

failing tests are related to "MAX_GROUPS_PER_ORG_EXCEEDED" issue in testing org, verified migration and acceptance tests are passing well.

@AgustinBettati AgustinBettati merged commit d4a2bce into master Nov 28, 2023
28 of 30 checks passed
@AgustinBettati AgustinBettati deleted the INTMDB-1296 branch November 28, 2023 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants