-
Notifications
You must be signed in to change notification settings - Fork 210
chore: Add module examples to User Management Guide and apply consistency in docs #4048
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
marcabreracast
merged 17 commits into
master
from
CLOUDP-344329_Add_Remaining_Module_Examples
Jan 12, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
87621df
Bundle basic resource migration into basic directory
marcabreracast e98419b
Maintain previous structrue for main file
marcabreracast 2ccd4a5
Add module_user example
marcabreracast b6a7111
Add module_maintainer example
marcabreracast 120a6e3
Add example links to migration guide docs
marcabreracast f3ea1c0
Minor fixes
marcabreracast bef0794
Bundle example into basic directory
marcabreracast 88624ab
Add module_maintainer example
marcabreracast 0d8fc06
Add module_user example
marcabreracast a4932fc
Add links to examples on Migration Guide
marcabreracast 5d15c60
Add main README and refine docs
marcabreracast e14e3f4
Rebundle Atlas user basic example and add example modules
marcabreracast 8de3a5f
Remove extra verbose module example for cloud user team assignment in…
marcabreracast 852b248
bundle README files from migration example into a single one for bett…
marcabreracast 05dac42
Rebundle project invitation READMEs into singular one for better read…
marcabreracast e8f4ebc
Address PR comments
marcabreracast 30ae758
Replace this hardcoded value with project_name variable
marcabreracast 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,12 @@ | ||
| # Migration Example: Atlas User to Cloud User Org Assignment | ||
|
|
||
| This example demonstrates how to migrate from the deprecated `mongodbatlas_atlas_user` and `mongodbatlas_atlas_users` data sources to their replacements. | ||
| This example demonstrates migrating from the deprecated `mongodbatlas_atlas_user` and `mongodbatlas_atlas_users` data sources to their replacements. | ||
|
|
||
| ## Migration Phases | ||
| ## Basic usage (direct data source usage) | ||
|
|
||
| ### v1: Initial State (Deprecated Data Sources) | ||
| Shows the original configuration using deprecated data sources: | ||
| - `mongodbatlas_atlas_user` for single user reads | ||
| - `mongodbatlas_atlas_users` for user lists | ||
| - [basic](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/migrate_atlas_user_and_atlas_users/basic): Direct data source usage. | ||
|
|
||
| ### v2: Migration Phase (Both Old and New) | ||
| Demonstrates the migration approach: | ||
| - Adds new data sources alongside old ones | ||
| - Shows attribute mapping examples | ||
| - Validates new data sources work before removing old ones | ||
| ## Module-based examples | ||
|
|
||
| ### v3: Final State (New Data Sources Only) | ||
| Clean final configuration using only: | ||
| - `mongodbatlas_cloud_user_org_assignment` for single user reads | ||
| - `mongodbatlas_organization.users`, `mongodbatlas_project.users`, `mongodbatlas_team.users` for user lists | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Start with v1 to understand the original setup | ||
| 2. Apply v2 configuration to add new data sources | ||
| 3. Verify the new data sources return expected data | ||
| 4. Update your references using the attribute mappings shown | ||
| 5. Apply v3 configuration for the final clean state | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - MongoDB Atlas Terraform Provider 2.0.0 or later | ||
| - Valid MongoDB Atlas organization, project, and team IDs | ||
| - Existing users in your organization | ||
|
|
||
| ## Variables | ||
|
|
||
| Set these variables for all versions: | ||
|
|
||
| ```terraform | ||
| client_id = "<ATLAS_CLIENT_ID>" # Optional, can use env vars | ||
| client_secret = "<ATLAS_CLIENT_SECRET>" # Optional, can use env vars | ||
| org_id = "your-organization-id" | ||
| project_id = "your-project-id" | ||
| team_id = "your-team-id" | ||
| user_id = "existing-user-id" | ||
| username = "[email protected]" | ||
| ``` | ||
|
|
||
| Alternatively, set environment variables: | ||
| ```bash | ||
| export MONGODB_ATLAS_CLIENT_ID="<ATLAS_CLIENT_ID>" | ||
| export MONGODB_ATLAS_CLIENT_SECRET="<ATLAS_CLIENT_SECRET>" | ||
| ``` | ||
| - [module_maintainer](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/migrate_atlas_user_and_atlas_users/module_maintainer): How module maintainers should migrate. | ||
| - [module_user](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples/migrate_atlas_user_and_atlas_users/module_user): How module consumers should migrate. |
74 changes: 74 additions & 0 deletions
74
examples/migrate_atlas_user_and_atlas_users/basic/README.md
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||||
| # Basic Migration Example: Atlas User Data Sources | ||||||
|
|
||||||
| This example demonstrates how to migrate from the deprecated `mongodbatlas_atlas_user` and `mongodbatlas_atlas_users` data sources to their replacements. | ||||||
|
|
||||||
| For migration steps, see the [Migration Guide](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/docs/guides/atlas-user-management.md). | ||||||
|
|
||||||
| ### v1: Initial State (Deprecated Data Sources) | ||||||
|
|
||||||
| Shows the original configuration using deprecated data sources: | ||||||
| - `mongodbatlas_atlas_user` for single user reads | ||||||
| - `mongodbatlas_atlas_users` for user lists | ||||||
|
|
||||||
| ### v2: Migration Phase | ||||||
|
|
||||||
| Runs both old and new data sources side-by-side to validate the migration. | ||||||
|
|
||||||
| **Key comparisons:** | ||||||
| - Single user: `email_address` → `username` | ||||||
| - Single user: Complex role filtering → Structured `roles.org_roles` and `roles.project_role_assignments` | ||||||
| - User lists: `results[*].email_address` → `users[*].username` | ||||||
|
|
||||||
| **Usage:** | ||||||
| 1. Apply this configuration: `terraform apply` | ||||||
| 2. Review the comparison outputs to verify data consistency | ||||||
| 3. Check `migration_validation.ready_for_v3` is `true` | ||||||
| 4. Once validated, proceed to v3 | ||||||
|
|
||||||
| **Expected outputs:** Side-by-side comparisons of email retrieval methods, role access patterns, user list structures, and count validations. | ||||||
|
|
||||||
| ### v3: Final State (New Data Sources Only) | ||||||
|
|
||||||
| Clean final configuration using only: | ||||||
| - `mongodbatlas_cloud_user_org_assignment` for single user reads | ||||||
| - `mongodbatlas_organization.users`, `mongodbatlas_project.users`, `mongodbatlas_team.users` for user lists | ||||||
|
|
||||||
| **Key improvements:** | ||||||
| - **Structured roles**: Organization and project roles are clearly separated | ||||||
| - **Direct access**: No need to filter consolidated role lists | ||||||
| - **Consistent naming**: `username` instead of `email_address` | ||||||
| - **Better organization**: User lists come from their natural containers (org/project/team) | ||||||
| - **Better performance**: Organization context required for user reads (more efficient API calls) | ||||||
|
|
||||||
| ## Usage | ||||||
|
|
||||||
| 1. Start with v1 to understand the original setup | ||||||
| 2. Apply v2 to validate new data sources return expected data | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 3. Apply v3 for the final clean state | ||||||
|
|
||||||
| ## Prerequisites | ||||||
|
|
||||||
| - MongoDB Atlas Terraform Provider 2.0.0 or later | ||||||
| - Valid MongoDB Atlas organization, project, and team IDs | ||||||
| - Existing users in your organization | ||||||
|
|
||||||
| ## Variables | ||||||
|
|
||||||
| Set these variables for all versions: | ||||||
|
|
||||||
| ```terraform | ||||||
| client_id = "<ATLAS_CLIENT_ID>" # Optional, can use env vars | ||||||
| client_secret = "<ATLAS_CLIENT_SECRET>" # Optional, can use env vars | ||||||
| org_id = "your-organization-id" | ||||||
| project_id = "your-project-id" | ||||||
| team_id = "your-team-id" | ||||||
| user_id = "existing-user-id" | ||||||
| username = "[email protected]" | ||||||
| ``` | ||||||
|
|
||||||
| Alternatively, set environment variables: | ||||||
|
|
||||||
| ```bash | ||||||
| export MONGODB_ATLAS_CLIENT_ID="<ATLAS_CLIENT_ID>" | ||||||
| export MONGODB_ATLAS_CLIENT_SECRET="<ATLAS_CLIENT_SECRET>" | ||||||
| ``` | ||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
examples/migrate_atlas_user_and_atlas_users/module_maintainer/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Module Maintainer Migration Example | ||
|
|
||
| This example demonstrates how module maintainers should migrate from the `mongodbatlas_atlas_user` data source to `mongodbatlas_cloud_user_org_assignment`. | ||
|
|
||
| For migration steps, see the [Migration Guide](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/docs/guides/atlas-user-management.md). | ||
|
|
||
| ## v1: Initial State | ||
|
|
||
| Module using the deprecated `mongodbatlas_atlas_user` data source: | ||
| - Complex role filtering with `for` expressions | ||
| - Separate `email_address` and `username` attributes | ||
| - Outputs: user_id, username, email_address, first_name, last_name, org_roles, project_roles | ||
|
|
||
| ## v2: Migration | ||
|
|
||
| - Replace `mongodbatlas_atlas_user` with `mongodbatlas_cloud_user_org_assignment` | ||
| - Simplified role access via `roles.org_roles` (no filtering needed for org roles) | ||
| - `email_address` now returns `username` | ||
| - Output names kept the same | ||
|
|
||
| See `module_user/v2` for an example of how to consume this module. | ||
|
|
||
| ## v3: Cleaned Up Configuration | ||
|
|
||
| Final module definition after migration is complete: | ||
| - Uses `mongodbatlas_cloud_user_org_assignment` data source | ||
| - Same outputs as v1/v2 |
Oops, something went wrong.
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.
similar to the ask in the other PR, you're using
masterinstead of a version tag (like in the code you removed just below here). Is this intentional?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.
It is intentional yes. I synced with Espen about this topic and left a follow-up comment in the other PR clarifying, but in summary, it's safe to leave
master, as when the release happens this script that we have replaces allmastertags with the fixed release version.