Skip to content

doc: Adds example & documentation for new mongodbatlas_cloud_user_team_assignment resource #3578

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

Open
wants to merge 19 commits into
base: CLOUDP-320243-dev-2.0.0
Choose a base branch
from

Conversation

csanx
Copy link
Collaborator

@csanx csanx commented Aug 11, 2025

Description

Adds example & documentation for new mongodbatlas_cloud_user_team_assignment resource

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

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

@csanx csanx marked this pull request as ready for review August 11, 2025 13:15
@Copilot Copilot AI review requested due to automatic review settings August 11, 2025 13:15
@csanx csanx requested review from a team as code owners August 11, 2025 13:15
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 comprehensive documentation and examples for the new mongodbatlas_cloud_user_team_assignment resource and data source, enabling users to assign and manage MongoDB Cloud users within teams.

Key changes:

  • Adds documentation templates for both resource and data source
  • Creates complete example implementation with Terraform configuration files
  • Generates final documentation files with schema details and usage examples

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
templates/resources/cloud_user_team_assignment.md.tmpl Template for resource documentation with import instructions
templates/data-sources/cloud_user_team_assignment.md.tmpl Template for data source documentation
examples/mongodbatlas_cloud_user_team_assignment/*.tf Complete Terraform example with provider, variables, main config, and outputs
examples/mongodbatlas_cloud_user_team_assignment/README.md Example usage documentation
docs/resources/cloud_user_team_assignment.md Generated resource documentation with schema
docs/data-sources/cloud_user_team_assignment.md Generated data source documentation with schema


-> **NOTE**Users with pending invitations created using the deprecated `mongodbatlas_project_invitation` resource or via the deprecated [Invite One MongoDB Cloud User to One Project](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser#tag/Projects/operation/createProjectInvitation)
endpoint cannot be managed with this resource. See [MongoDB Atlas API](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-listteamusers) for details.
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The migration guide link is incomplete with placeholder text '' instead of an actual URL.

Suggested change
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
To manage such users with this resource, refer to our [migration guide](https://www.mongodb.com/docs/atlas/migrate-cloud-user-team-assignment).

Copilot uses AI. Check for mistakes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All placeholders will be addressed as part of this ticket CLOUDP-329711

@@ -0,0 +1,17 @@
resource "mongodbatlas_cloud_user_team_assignment" "example" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the data sources depend on the resource?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had the same question earlier but couldn’t find an example where depends_on is used, only data sources using it when a different resource is needed.
Also, we didn’t include this in cloud_user_org_assignment docs #3493, so I did not included it here for consistency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you run the example? I suspect it will fail, since the data source will get NOT FOUND until the resource is created. But maybe we are handling that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it fails. The cloud_user_org_assignment example fails for the same reason. Agustin pointed out that the other examples I reviewed without depends_on implicitly depend on the resource because they reference its attributes, so it’s a different situation.
I’ll update both examples to include a depends_on

@@ -0,0 +1,75 @@
# Data Source: mongodbatlas_cloud_user_team_assignment
Copy link
Collaborator

Choose a reason for hiding this comment

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

not related to this PR, but in case you didn't know, you can use https://registry.terraform.io/tools/doc-preview - learned it from @AgustinBettati

Copy link
Member

Choose a reason for hiding this comment

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

it's also in the makefile

@echo "Use this site to preview markdown rendering: https://registry.terraform.io/tools/doc-preview"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Already used that! It was super helpful for detecting small issues 👍🏻


-> **NOTE**Users with pending invitations created using the deprecated `mongodbatlas_project_invitation` resource or via the deprecated [Invite One MongoDB Cloud User to One Project](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser#tag/Projects/operation/createProjectInvitation)
endpoint cannot be managed with this resource. See [MongoDB Atlas API](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-listteamusers) for details.
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
Copy link
Collaborator

Choose a reason for hiding this comment

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

sweet!

Copy link
Collaborator

Choose a reason for hiding this comment

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

one note: to make sure we really don't forget these placeholder links (<link-to-migration-guide>) I would probably stay consistent with the same keyword (the one you've used <link-to-migration-guide> is ok) and then create a CLOUDP ticket to search for all those occurrences.

This is valid if you're planning to merge this PR with that placeholder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, we already have a ticket CLOUDP-329711
I updated the description to flag that this is the specific keyword.

@@ -0,0 +1,28 @@
# Example: mongodbatlas_cloud_user_team_assignment
Copy link
Collaborator

Choose a reason for hiding this comment

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

@maastha @csanx this example is great. Will we have one example created specifically for the migration though? Like we had when we've created mongodbatlas_api_key_assignment and had to provide a migration path for mongodbatlas_project_api_key (https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/mongodbatlas_api_key_assignment/module/old_module)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think what you are suggesting will be done in the following tickets, that are specifically for designing the migration guides.

Copy link
Collaborator

Choose a reason for hiding this comment

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

perfect!


Read-Only:

- `org_roles` (Set of String) One or more organization level roles to assign the MongoDB Cloud user.
Copy link
Collaborator

Choose a reason for hiding this comment

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

we usually use "list" or "array" in the docs instead of "set". Does the distinction matter here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Autogenerated


### Required

- `org_id` (String) Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.
Copy link
Collaborator

Choose a reason for hiding this comment

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

data types here should all be lowercase. i.e. (String) -> (string)

another question here: do we usually add the data type? looking over a smattering of resource and data source examples and I don't see this as a common convention. Is this from the generated schema?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, autogenerated

- `mobile_number` (String) Mobile phone number that belongs to the MongoDB Cloud user.
- `org_membership_status` (String) 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` (Attributes) Organization and project level roles to assign the MongoDB Cloud user within one organization. (see [below for nested schema](#nestedatt--roles))
- `team_ids` (Set of String) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

see comment below as well re: set

Suggested change
- `team_ids` (Set of String) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs.
- `team_ids` (set of strings) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Autogenerated

- `last_name` (String) Last name, family name, or surname that belongs to the MongoDB Cloud user.
- `mobile_number` (String) Mobile phone number that belongs to the MongoDB Cloud user.
- `org_membership_status` (String) 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` (Attributes) Organization and project level roles to assign the MongoDB Cloud user within one organization. (see [below for nested schema](#nestedatt--roles))
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't often use "attributes" in the docs. Is this an object / list of objects?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Autogenerated


Read-Only:

- `org_roles` (Set of String) One or more organization level roles to assign the MongoDB Cloud user.
Copy link
Collaborator

Choose a reason for hiding this comment

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

string should be plural

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Autogenerated

### Required

- `org_id` (String) Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.
- `team_id` (String) Unique 24-hexadecimal digit string that identifies the team to which you want to assign the MongoDB Cloud user. Use the [/teams](#tag/Teams/operation/listTeams) endpoint to retrieve all teams to which the authenticated user has access.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this relative link should be replaced with an absolute one

### Required

- `org_id` (String) Unique 24-hexadecimal digit string that identifies the organization that contains your projects. Use the [/orgs](#tag/Organizations/operation/listOrganizations) endpoint to retrieve all organizations to which the authenticated user has access.
- `team_id` (String) Unique 24-hexadecimal digit string that identifies the team to which you want to assign the MongoDB Cloud user. Use the [/teams](#tag/Teams/operation/listTeams) endpoint to retrieve all teams to which the authenticated user has access.
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace relative link with absolute link to API docs. Or should this be updated to link to a terraform construct?

@@ -0,0 +1,82 @@
# Resource: mongodbatlas_cloud_user_team_assignment

`mongodbatlas_cloud_user_team_assignment` provides a Cloud User Team Assignment resource. The resource lets you import, assign, remove, or update a user to a team.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"update a user to a team" is somewhat uncommon construction. Is there a different verb we could use to better describe the behavior?

@csanx
Copy link
Collaborator Author

csanx commented Aug 12, 2025

Thanks for the review @jwilliams-mongo! Most of your comments refer to autogenerated parts of the documentation, which I can’t change manually. This convention is more recent, so only newer resources follow it (e.g., mongodbatlas_api_key_project_assignment, mongodbatlas_flex_cluster).

Generating the documentation automatically will ensure consistency across all docs created from now on. I’ll mark in your suggestions which sections are autogenerated so it’s clear which ones I cannot address.

Cristina Sánchez Sánchez added 2 commits August 12, 2025 11:53
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.

6 participants