Skip to content

Conversation

csanx
Copy link

@csanx csanx commented Aug 14, 2025

Description

Migration guide for mongodbatlas_team.usernames attribute to the mongodbatlas_cloud_user_team_assignment resource

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

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

Tested the migration paths successfully.

@csanx csanx changed the title Migration guide for mongodbatlas_team.usernames attribute to the mongodbatlas_cloud_user_team_assignment resource doc: Migration guide for mongodbatlas_team.usernames attribute to the mongodbatlas_cloud_user_team_assignment resource Aug 14, 2025
@csanx csanx requested a review from a team August 14, 2025 09:44
@csanx csanx marked this pull request as ready for review August 14, 2025 09:48
@Copilot Copilot AI review requested due to automatic review settings August 14, 2025 09:48
@csanx csanx requested a review from a team as a code owner August 14, 2025 09:48
Copy link
Contributor

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

@csanx
Copy link
Author

csanx commented Aug 14, 2025

@marcosuma I’m not sure we need an example created specifically for this migration, since we’re not doing anything different to support modules. Do you think it’s worth adding one?

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 comprehensive migration guide to help users transition from the deprecated usernames attribute on the mongodbatlas_team resource to the new mongodbatlas_cloud_user_team_assignment resource.

Key changes:

  • Added detailed migration documentation with step-by-step instructions
  • Provided practical Terraform code examples for each migration step
  • Included guidance on handling imports and module considerations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


---

### Step 1: User `mongodb_atlas_team` data source to retrieve user IDs
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

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

Typo in heading: 'User' should be 'Use'.

Suggested change
### Step 1: User `mongodb_atlas_team` data source to retrieve user IDs
### Step 1: Use `mongodb_atlas_team` data source to retrieve user IDs

Copilot uses AI. Check for mistakes.

}

# New resource for each (user, team) assignment
resource "mongodbatlas_cloud_user_team_assignment" "this" {
Copy link
Preview

Copilot AI Aug 14, 2025

Choose a reason for hiding this comment

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

Extra space before 'resource' keyword. Should be aligned with other resource blocks.

Suggested change
resource "mongodbatlas_cloud_user_team_assignment" "this" {
resource "mongodbatlas_cloud_user_team_assignment" "this" {

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@marcosuma marcosuma left a comment

Choose a reason for hiding this comment

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

@csanx I would still add an example for modules so it'll be crystal clear to customers what root-level import blocks means.


Handling migration in modules

- Terraform import blocks cannot live inside modules; they must be defined in the root module. See ([Terraform issue](https://github.com/hashicorp/terraform/issues/33474)).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Terraform import blocks cannot live inside modules; they must be defined in the root module. See ([Terraform issue](https://github.com/hashicorp/terraform/issues/33474)).
- Terraform import blocks cannot live inside modules; See ([Terraform issue](https://github.com/hashicorp/terraform/issues/33474)).

found this sentence duplicating the one just after

Copy link
Author

Choose a reason for hiding this comment

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

Rewrote it

Copy link
Contributor

@corryroot corryroot left a comment

Choose a reason for hiding this comment

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

LGTM


- `mongodbatlas_team` included a `usernames` argument that allowed assigning users to a team directly inside the resource. This argument is now deprecated.
- New attribute `users` in `mongodbatlas_team` data source can be used to retrieve information about all the users assigned to that team.
- `mongodbatlas_cloud_user_team_assignment` manages the user’s organization membership (pending or active) and exposes both `username` and `user_id`. It supports import using either `ORG_ID/TEAM_ID/USERNAME` or `ORG_ID/TEAM_ID/USER_ID`.
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 be "manages the user’s team membership ....."?

Copy link
Author

Choose a reason for hiding this comment

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

Yes! Changed it


- `mongodbatlas_team` included a `usernames` argument that allowed assigning users to a team directly inside the resource. This argument is now deprecated.
- New attribute `users` in `mongodbatlas_team` data source can be used to retrieve information about all the users assigned to that team.
- `mongodbatlas_cloud_user_team_assignment` manages the user’s organization membership (pending or active) and exposes both `username` and `user_id`. It supports import using either `ORG_ID/TEAM_ID/USERNAME` or `ORG_ID/TEAM_ID/USER_ID`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] is there any difference between pending vs active behavior?

Copy link
Author

Choose a reason for hiding this comment

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

There shouldn't be. I've just tried it and it imports both, pending and active users. You can also add a pending user to a team.


---

### Step 1: User `mongodb_atlas_team` data source to retrieve user IDs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
### Step 1: User `mongodb_atlas_team` data source to retrieve user IDs
### Step 1: Use `mongodbatlas_team` data source to retrieve user IDs

resource "mongodbatlas_team" "this" {
org_id = var.org_id
name = "this"
# usernames = local.usernames # Remove this line
Copy link
Member

Choose a reason for hiding this comment

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

I see usernames is not present in configs of step 1 and 2. We should add them there right?

Copy link
Author

Choose a reason for hiding this comment

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

You're right. Included them.

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

@oarbusi
Copy link
Collaborator

oarbusi commented Aug 22, 2025

merging as @csanx addressed all the comments

@oarbusi oarbusi merged commit 1096236 into CLOUDP-320243-dev-2.0.0 Aug 22, 2025
42 checks passed
@oarbusi oarbusi deleted the CLOUDP-336760 branch August 22, 2025 13:36
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.

7 participants