-
Notifications
You must be signed in to change notification settings - Fork 204
doc: Adds example & documentation for new mongodbatlas_cloud_user_org_assignment
resource
#3493
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
maastha
wants to merge
43
commits into
CLOUDP-320243-dev-2.0.0
Choose a base branch
from
CLOUDP-329817-cloud-user-org-ex-docs
base: CLOUDP-320243-dev-2.0.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+295
−0
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
521c29d
init
maastha 50461ab
test,examples
maastha 826229d
test,examples
maastha de9d081
Merge branch 'CLOUDP-320243-dev-2.0.0' into CLOUDP-329812-cloud-user-…
maastha 181ae68
changelog
maastha 84e2dca
tests
maastha e9ae785
min
maastha 4fc35a9
update tests
maastha 6d978fd
lint
maastha acd7625
add github and mig test
maastha b76e316
min
maastha 4299860
cleanup
maastha 6ecb199
min
maastha 9af33a2
data source
maastha 8549f3e
pr comments
maastha 6812cf8
Merge branch 'CLOUDP-320243-dev-2.0.0' into CLOUDP-329812-cloud-user-…
maastha b6f41c8
Merge branch 'CLOUDP-329812-cloud-user-org-resource' into CLOUDP-3298…
maastha e93bb0f
changelog
maastha 4fd8883
min
maastha 7e1372e
Merge branch 'CLOUDP-329812-cloud-user-org-resource' into CLOUDP-3298…
maastha 0cbaf00
test,examples
maastha b463342
init
maastha c0591aa
min
maastha 5f01691
min
maastha a13d61b
lint
maastha faaf64b
min
maastha 29ed588
Merge branch 'CLOUDP-320243-dev-2.0.0' into CLOUDP-329812-cloud-user-…
maastha fee0ec0
update move
maastha 76d18e9
feat: Adds new singular data source `mongodbatlas_cloud_user_org_assi…
maastha a9f5cfe
Update docs/resources/cloud_user_org_assignment.md
maastha 25a8ade
Merge branch 'CLOUDP-329812-cloud-user-org-resource' of github.com:mo…
maastha 5597465
pr comments
maastha e25dea7
min
maastha e8647b1
Merge branch 'CLOUDP-329812-cloud-user-org-resource' into CLOUDP-3298…
maastha 3c98afc
min
maastha 429cb5a
Merge branch 'CLOUDP-320243-dev-2.0.0' into CLOUDP-329817-cloud-user-…
maastha 4710e4a
min
maastha 2ccfa6f
min
maastha fafdbc3
min
maastha 982b2f1
ut
maastha 80b4fba
tmp
maastha e536ca2
format examples
oarbusi 83cc568
doc update
oarbusi 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Data Source: mongodbatlas_cloud_user_org_assignment | ||
|
||
`mongodbatlas_cloud_user_org_assignment` provides a Cloud User Organization Assignment data source. The data source lets you retrieve a user assigned to an organization. | ||
|
||
**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 are not returned with this resource. See [MongoDB Atlas API](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser) for details. | ||
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>. | ||
|
||
## Example Usages | ||
|
||
```terraform | ||
resource "mongodbatlas_cloud_user_org_assignment" "example" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
roles = { | ||
org_roles = ["ORG_MEMBER"] | ||
} | ||
} | ||
|
||
data "mongodbatlas_cloud_user_org_assignment" "example_username" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
} | ||
|
||
data "mongodbatlas_cloud_user_org_assignment" "example_user_id" { | ||
org_id = var.org_id | ||
user_id = var.user_id | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### 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. | ||
|
||
### Optional | ||
|
||
- `user_id` (String) Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user. | ||
- `username` (String) Email address that represents the username of the MongoDB Cloud user. | ||
|
||
### Read-Only | ||
|
||
- `country` (String) Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format. | ||
- `created_at` (String) Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC. | ||
- `first_name` (String) First or given name that belongs to the MongoDB Cloud user. | ||
- `invitation_created_at` (String) Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC. | ||
- `invitation_expires_at` (String) Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC. | ||
- `inviter_username` (String) Username of the MongoDB Cloud user who sent the invitation to join the organization. | ||
- `last_auth` (String) Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC. | ||
- `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)) | ||
- `team_ids` (Set of String) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs. | ||
|
||
<a id="nestedatt--roles"></a> | ||
### Nested Schema for `roles` | ||
|
||
Read-Only: | ||
|
||
- `org_roles` (Set of String) One or more organization level roles to assign the MongoDB Cloud user. | ||
- `project_role_assignments` (Attributes List) List of project level role assignments to assign the MongoDB Cloud user. (see [below for nested schema](#nestedatt--roles--project_role_assignments)) | ||
|
||
<a id="nestedatt--roles--project_role_assignments"></a> | ||
### Nested Schema for `roles.project_role_assignments` | ||
|
||
Read-Only: | ||
|
||
- `project_id` (String) Unique 24-hexadecimal digit string that identifies the project to which these roles belong. | ||
- `project_roles` (Set of String) One or more project-level roles assigned to the MongoDB Cloud user. | ||
|
||
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser) Documentation. |
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,84 @@ | ||
# Resource: mongodbatlas_cloud_user_org_assignment | ||
|
||
`mongodbatlas_cloud_user_org_assignment` provides a Cloud User Organization Assignment resource. The resource lets you import, assign, remove, or update a user to an organization. | ||
|
||
**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-getorganizationuser) for details. | ||
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>. | ||
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. same as resource, correct migration guide link? 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. same as above |
||
|
||
## Example Usages | ||
|
||
```terraform | ||
resource "mongodbatlas_cloud_user_org_assignment" "example" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
roles = { | ||
org_roles = ["ORG_MEMBER"] | ||
} | ||
} | ||
|
||
data "mongodbatlas_cloud_user_org_assignment" "example_username" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
} | ||
|
||
data "mongodbatlas_cloud_user_org_assignment" "example_user_id" { | ||
org_id = var.org_id | ||
user_id = var.user_id | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### 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. | ||
- `roles` (Attributes) Organization and project level roles to assign the MongoDB Cloud user within one organization. (see [below for nested schema](#nestedatt--roles)) | ||
- `username` (String) Email address that represents the username of the MongoDB Cloud user. | ||
|
||
### Read-Only | ||
|
||
- `country` (String) Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format. | ||
- `created_at` (String) Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC. | ||
- `first_name` (String) First or given name that belongs to the MongoDB Cloud user. | ||
- `invitation_created_at` (String) Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC. | ||
- `invitation_expires_at` (String) Date and time when the invitation from MongoDB Cloud expires. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC. | ||
- `inviter_username` (String) Username of the MongoDB Cloud user who sent the invitation to join the organization. | ||
- `last_auth` (String) Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC. | ||
- `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. | ||
- `team_ids` (Set of String) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs. | ||
- `user_id` (String) Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user. | ||
|
||
<a id="nestedatt--roles"></a> | ||
### Nested Schema for `roles` | ||
|
||
Optional: | ||
|
||
- `org_roles` (Set of String) One or more organization level roles to assign the MongoDB Cloud user. | ||
|
||
Read-Only: | ||
|
||
- `project_role_assignments` (Attributes List) List of project level role assignments to assign the MongoDB Cloud user. (see [below for nested schema](#nestedatt--roles--project_role_assignments)) | ||
|
||
<a id="nestedatt--roles--project_role_assignments"></a> | ||
### Nested Schema for `roles.project_role_assignments` | ||
|
||
Read-Only: | ||
|
||
- `project_id` (String) Unique 24-hexadecimal digit string that identifies the project to which these roles belong. | ||
- `project_roles` (Set of String) One or more project-level roles assigned to the MongoDB Cloud user. | ||
|
||
## Import | ||
|
||
Cloud User Org Assignment resource can be imported using the Org ID & Username OR Org ID & User ID, in the format `ORG_ID/USERNAME` OR `ORG_ID/USER_ID`. | ||
|
||
``` | ||
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/[email protected] | ||
OR | ||
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/5f18367ccb7a503a2b481b7a | ||
``` | ||
|
||
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createorganizationuser) Documentation. |
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,29 @@ | ||
# Example: mongodbatlas_cloud_user_org_assignment | ||
|
||
This example demonstrates how to use the `mongodbatlas_cloud_user_org_assignment` resource to assign a user to an existing organization with specified roles in MongoDB Atlas. | ||
|
||
## Usage | ||
|
||
```hcl | ||
provider "mongodbatlas" { | ||
public_key = var.public_key | ||
private_key = var.private_key | ||
} | ||
|
||
resource "mongodbatlas_cloud_user_org_assignment" "example" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
roles = { | ||
org_roles = ["ORG_MEMBER"] | ||
} | ||
} | ||
``` | ||
|
||
You must set the following variables: | ||
|
||
- `public_key`: Your MongoDB Atlas API public key. | ||
- `private_key`: Your MongoDB Atlas API private key. | ||
- `org_id`: The ID of the organization to assign the user to. | ||
- `user_email`: The email address of the user to assign. | ||
|
||
To learn more, see the [MongoDB Cloud Users Documentation](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createorganizationuser). |
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,17 @@ | ||
resource "mongodbatlas_cloud_user_org_assignment" "example" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
roles = { | ||
org_roles = ["ORG_MEMBER"] | ||
} | ||
} | ||
|
||
data "mongodbatlas_cloud_user_org_assignment" "example_username" { | ||
org_id = var.org_id | ||
username = var.user_email | ||
} | ||
|
||
data "mongodbatlas_cloud_user_org_assignment" "example_user_id" { | ||
org_id = var.org_id | ||
user_id = var.user_id | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/mongodbatlas_cloud_user_org_assignment/outputs.tf
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,14 @@ | ||
output "user_from_username" { | ||
description = "User details retrieved by username" | ||
value = data.mongodbatlas_cloud_user_org_assignment.example_username | ||
} | ||
|
||
output "user_from_user_id" { | ||
description = "User details retrieved by user_id" | ||
value = data.mongodbatlas_cloud_user_org_assignment.example_user_id | ||
} | ||
|
||
output "created_user" { | ||
description = "Details of the created user" | ||
value = mongodbatlas_cloud_user_org_assignment.example | ||
} |
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,4 @@ | ||
provider "mongodbatlas" { | ||
public_key = var.public_key | ||
private_key = var.private_key | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/mongodbatlas_cloud_user_org_assignment/variables.tf
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,24 @@ | ||
variable "org_id" { | ||
description = "The MongoDB Atlas organization ID" | ||
type = string | ||
} | ||
|
||
variable "user_email" { | ||
description = "The email address of the user" | ||
type = string | ||
} | ||
|
||
variable "user_id" { | ||
description = "The user ID" | ||
type = string | ||
} | ||
|
||
variable "public_key" { | ||
description = "Atlas API public key" | ||
type = string | ||
} | ||
|
||
variable "private_key" { | ||
description = "Atlas API private key" | ||
type = string | ||
} |
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,9 @@ | ||
terraform { | ||
required_providers { | ||
mongodbatlas = { | ||
source = "mongodb/mongodbatlas" | ||
version = "~> 1.38" | ||
} | ||
} | ||
required_version = ">= 1.0" | ||
} |
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,15 @@ | ||
# {{.Type}}: {{.Name}} | ||
|
||
`{{.Name}}` provides a Cloud User Organization Assignment data source. The data source lets you retrieve a user assigned to an organization. | ||
|
||
**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 are not returned with this resource. See [MongoDB Atlas API](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser) for details. | ||
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>. | ||
|
||
## Example Usages | ||
|
||
{{ tffile (printf "examples/%s/main.tf" .Name )}} | ||
|
||
{{ .SchemaMarkdown | trimspace }} | ||
|
||
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser) Documentation. |
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,25 @@ | ||
# {{.Type}}: {{.Name}} | ||
|
||
`{{.Name}}` provides a Cloud User Organization Assignment resource. The resource lets you import, assign, remove, or update a user to an organization. | ||
|
||
**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-getorganizationuser) for details. | ||
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>. | ||
|
||
## Example Usages | ||
|
||
{{ tffile (printf "examples/%s/main.tf" .Name )}} | ||
|
||
{{ .SchemaMarkdown | trimspace }} | ||
|
||
## Import | ||
|
||
Cloud User Org Assignment resource can be imported using the Org ID & Username OR Org ID & User ID, in the format `ORG_ID/USERNAME` OR `ORG_ID/USER_ID`. | ||
|
||
``` | ||
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/[email protected] | ||
OR | ||
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/5f18367ccb7a503a2b481b7a | ||
``` | ||
|
||
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createorganizationuser) Documentation. |
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.
Uh oh!
There was an error while loading. Please reload this page.