Skip to content

Conversation

csanx
Copy link
Contributor

@csanx csanx commented Jul 16, 2025

Description

Adds new mongodbatlas_cloud_user_team_assignment resource.

Additionally changed the attribute name project_roles_assignments to project_role_assignments in organization and team DS for consistency in naming.

Follow-up PRs:

Datasource
Examples & documentation

Link to any related issue(s): CLOUDP-329984

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. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • 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 have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

Cristina Sánchez Sánchez added 2 commits July 16, 2025 15:58
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/mig"
)

func TestMigCloudUserTeamAssignmentRS_basic(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we add test fro migration journeys to this resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we do not have a clear migration journey at the moment we will do it in a separate pr

Cristina Sánchez Sánchez added 3 commits July 21, 2025 11:51
@csanx
Copy link
Contributor Author

csanx commented Jul 21, 2025

Only Alert Config tests are failing (same as in master)

@csanx csanx marked this pull request as ready for review July 21, 2025 14:08
@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 14:08
@csanx csanx requested review from a team as code owners July 21, 2025 14:08
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new mongodbatlas_cloud_user_team_assignment resource to the MongoDB Atlas Terraform provider, enabling management of user-to-team assignments within an organization. The implementation also includes a field name correction for project role assignments across multiple existing resources.

  • Implements the new cloud user team assignment resource with complete CRUD operations and import functionality
  • Corrects field naming from project_roles_assignments to project_role_assignments across existing data sources for consistency
  • Adds comprehensive test coverage including unit tests, acceptance tests, and migration tests

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/service/clouduserteamassignment/* Complete implementation of the new resource including schema, model conversion, CRUD operations, and tests
internal/service/team/data_source_team_test.go Updates test to use corrected field name project_role_assignments
internal/service/organization/resource_organization_test.go Updates tests to use corrected field name project_role_assignments
internal/common/dsschema/users_schema.go Corrects schema field name from project_roles_assignments to project_role_assignments
internal/common/conversion/flatten_expand.go Updates flattening logic to use corrected field name
internal/provider/provider.go Registers the new resource with the provider
.github/workflows/acceptance-tests-runner.yml Adds CI configuration for the new resource tests
.changelog/3502.txt Documents the new resource addition

Copy link

@ytineo-mongodb ytineo-mongodb left a comment

Choose a reason for hiding this comment

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

LGTM

MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.",
},
"username": schema.StringAttribute{
Computed: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am a bit surprised we are requiring user_id and not username.
I think it is easier for a customer to use username, but maybe I missed the discussion in the technical design?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API requires user_id attribute. If we put usernames as computed instead of user_id, we would have to implement extra logic to retrieve user_id in order to call the API.
In short, the reason is that we wanted to be aligned with the API.
Additionally, we do support import with username.
Further discussion will be done in today's sync

},
},
},
"team_ids": schema.SetAttribute{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we including this? Is there no other way for the user to get this info?

Computed: true,
MarkdownDescription: "String enum that indicates whether the MongoDB Cloud user has a pending invitation to join the organization or they are already active in the organization.",
},
"roles": schema.SingleNestedAttribute{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as about the team_ids.
I think the roles for the team would make sense but not all roles?

Copy link
Contributor Author

@csanx csanx Jul 22, 2025

Choose a reason for hiding this comment

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

Again, the reason behind this is that we want to be aligned with what the API returns.
The same for team_ids

Copy link
Member

Choose a reason for hiding this comment

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

I did find roles and team_ids strange within this resource as well, but I see why we have added them. Are both of the attributes also present in cloud_user_org_assignment?

Copy link
Collaborator

@oarbusi oarbusi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM, leaving some improvement suggestions

Comment on lines 60 to 63
map[string]attr.Value{
"org_roles": orgRoles,
"project_role_assignments": projectRoleAssignmentsSet,
},
Copy link
Member

Choose a reason for hiding this comment

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

q: Any reason why we don't use the typed model TFRolesModel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just an oversight on my part. I'll update it to use TFRolesModel

Comment on lines 151 to 152
func (r *rs) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
}
Copy link
Member

Choose a reason for hiding this comment

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

Cristina Sánchez Sánchez and others added 2 commits July 23, 2025 10:58
…ignment` (#3517)

* Added DS schema generation and Read operation

* Add to provider

* Fix

* Added tests

* Changelog

* Modified tests

* Removed redundant condition

* Removed IsUserID

---------

Co-authored-by: Cristina Sánchez Sánchez <[email protected]>
@csanx csanx merged commit f166785 into CLOUDP-320243-dev-2.0.0 Jul 28, 2025
75 of 76 checks passed
@csanx csanx deleted the CLOUDP-329984 branch July 28, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants