Skip to content

Commit e212c81

Browse files
authored
doc: Adds example & documentation for new mongodbatlas_cloud_user_org_assignment resource (#3493)
1 parent f91f46c commit e212c81

File tree

10 files changed

+295
-0
lines changed

10 files changed

+295
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Data Source: mongodbatlas_cloud_user_org_assignment
2+
3+
`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.
4+
5+
**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)
6+
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.
7+
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
8+
9+
## Example Usages
10+
11+
```terraform
12+
resource "mongodbatlas_cloud_user_org_assignment" "example" {
13+
org_id = var.org_id
14+
username = var.user_email
15+
roles = {
16+
org_roles = ["ORG_MEMBER"]
17+
}
18+
}
19+
20+
data "mongodbatlas_cloud_user_org_assignment" "example_username" {
21+
org_id = var.org_id
22+
username = var.user_email
23+
}
24+
25+
data "mongodbatlas_cloud_user_org_assignment" "example_user_id" {
26+
org_id = var.org_id
27+
user_id = var.user_id
28+
}
29+
```
30+
31+
<!-- schema generated by tfplugindocs -->
32+
## Schema
33+
34+
### Required
35+
36+
- `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.
37+
38+
### Optional
39+
40+
- `user_id` (String) Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
41+
- `username` (String) Email address that represents the username of the MongoDB Cloud user.
42+
43+
### Read-Only
44+
45+
- `country` (String) Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
46+
- `created_at` (String) Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
47+
- `first_name` (String) First or given name that belongs to the MongoDB Cloud user.
48+
- `invitation_created_at` (String) Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
49+
- `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.
50+
- `inviter_username` (String) Username of the MongoDB Cloud user who sent the invitation to join the organization.
51+
- `last_auth` (String) Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
52+
- `last_name` (String) Last name, family name, or surname that belongs to the MongoDB Cloud user.
53+
- `mobile_number` (String) Mobile phone number that belongs to the MongoDB Cloud user.
54+
- `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.
55+
- `roles` (Attributes) Organization and project level roles to assign the MongoDB Cloud user within one organization. (see [below for nested schema](#nestedatt--roles))
56+
- `team_ids` (Set of String) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs.
57+
58+
<a id="nestedatt--roles"></a>
59+
### Nested Schema for `roles`
60+
61+
Read-Only:
62+
63+
- `org_roles` (Set of String) One or more organization level roles to assign the MongoDB Cloud user.
64+
- `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))
65+
66+
<a id="nestedatt--roles--project_role_assignments"></a>
67+
### Nested Schema for `roles.project_role_assignments`
68+
69+
Read-Only:
70+
71+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies the project to which these roles belong.
72+
- `project_roles` (Set of String) One or more project-level roles assigned to the MongoDB Cloud user.
73+
74+
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser) Documentation.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Resource: mongodbatlas_cloud_user_org_assignment
2+
3+
`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.
4+
5+
**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)
6+
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.
7+
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
8+
9+
## Example Usages
10+
11+
```terraform
12+
resource "mongodbatlas_cloud_user_org_assignment" "example" {
13+
org_id = var.org_id
14+
username = var.user_email
15+
roles = {
16+
org_roles = ["ORG_MEMBER"]
17+
}
18+
}
19+
20+
data "mongodbatlas_cloud_user_org_assignment" "example_username" {
21+
org_id = var.org_id
22+
username = var.user_email
23+
}
24+
25+
data "mongodbatlas_cloud_user_org_assignment" "example_user_id" {
26+
org_id = var.org_id
27+
user_id = var.user_id
28+
}
29+
```
30+
31+
<!-- schema generated by tfplugindocs -->
32+
## Schema
33+
34+
### Required
35+
36+
- `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.
37+
- `roles` (Attributes) Organization and project level roles to assign the MongoDB Cloud user within one organization. (see [below for nested schema](#nestedatt--roles))
38+
- `username` (String) Email address that represents the username of the MongoDB Cloud user.
39+
40+
### Read-Only
41+
42+
- `country` (String) Two-character alphabetical string that identifies the MongoDB Cloud user's geographic location. This parameter uses the ISO 3166-1a2 code format.
43+
- `created_at` (String) Date and time when MongoDB Cloud created the current account. This value is in the ISO 8601 timestamp format in UTC.
44+
- `first_name` (String) First or given name that belongs to the MongoDB Cloud user.
45+
- `invitation_created_at` (String) Date and time when MongoDB Cloud sent the invitation. MongoDB Cloud represents this timestamp in ISO 8601 format in UTC.
46+
- `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.
47+
- `inviter_username` (String) Username of the MongoDB Cloud user who sent the invitation to join the organization.
48+
- `last_auth` (String) Date and time when the current account last authenticated. This value is in the ISO 8601 timestamp format in UTC.
49+
- `last_name` (String) Last name, family name, or surname that belongs to the MongoDB Cloud user.
50+
- `mobile_number` (String) Mobile phone number that belongs to the MongoDB Cloud user.
51+
- `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.
52+
- `team_ids` (Set of String) List of unique 24-hexadecimal digit strings that identifies the teams to which this MongoDB Cloud user belongs.
53+
- `user_id` (String) Unique 24-hexadecimal digit string that identifies the MongoDB Cloud user.
54+
55+
<a id="nestedatt--roles"></a>
56+
### Nested Schema for `roles`
57+
58+
Optional:
59+
60+
- `org_roles` (Set of String) One or more organization level roles to assign the MongoDB Cloud user.
61+
62+
Read-Only:
63+
64+
- `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))
65+
66+
<a id="nestedatt--roles--project_role_assignments"></a>
67+
### Nested Schema for `roles.project_role_assignments`
68+
69+
Read-Only:
70+
71+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies the project to which these roles belong.
72+
- `project_roles` (Set of String) One or more project-level roles assigned to the MongoDB Cloud user.
73+
74+
## Import
75+
76+
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`.
77+
78+
```
79+
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/[email protected]
80+
OR
81+
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/5f18367ccb7a503a2b481b7a
82+
```
83+
84+
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createorganizationuser) Documentation.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Example: mongodbatlas_cloud_user_org_assignment
2+
3+
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.
4+
5+
## Usage
6+
7+
```hcl
8+
provider "mongodbatlas" {
9+
public_key = var.public_key
10+
private_key = var.private_key
11+
}
12+
13+
resource "mongodbatlas_cloud_user_org_assignment" "example" {
14+
org_id = var.org_id
15+
username = var.user_email
16+
roles = {
17+
org_roles = ["ORG_MEMBER"]
18+
}
19+
}
20+
```
21+
22+
You must set the following variables:
23+
24+
- `public_key`: Your MongoDB Atlas API public key.
25+
- `private_key`: Your MongoDB Atlas API private key.
26+
- `org_id`: The ID of the organization to assign the user to.
27+
- `user_email`: The email address of the user to assign.
28+
29+
To learn more, see the [MongoDB Cloud Users Documentation](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createorganizationuser).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource "mongodbatlas_cloud_user_org_assignment" "example" {
2+
org_id = var.org_id
3+
username = var.user_email
4+
roles = {
5+
org_roles = ["ORG_MEMBER"]
6+
}
7+
}
8+
9+
data "mongodbatlas_cloud_user_org_assignment" "example_username" {
10+
org_id = var.org_id
11+
username = var.user_email
12+
}
13+
14+
data "mongodbatlas_cloud_user_org_assignment" "example_user_id" {
15+
org_id = var.org_id
16+
user_id = var.user_id
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
output "user_from_username" {
2+
description = "User details retrieved by username"
3+
value = data.mongodbatlas_cloud_user_org_assignment.example_username
4+
}
5+
6+
output "user_from_user_id" {
7+
description = "User details retrieved by user_id"
8+
value = data.mongodbatlas_cloud_user_org_assignment.example_user_id
9+
}
10+
11+
output "created_user" {
12+
description = "Details of the created user"
13+
value = mongodbatlas_cloud_user_org_assignment.example
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "mongodbatlas" {
2+
public_key = var.public_key
3+
private_key = var.private_key
4+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "org_id" {
2+
description = "The MongoDB Atlas organization ID"
3+
type = string
4+
}
5+
6+
variable "user_email" {
7+
description = "The email address of the user"
8+
type = string
9+
}
10+
11+
variable "user_id" {
12+
description = "The user ID"
13+
type = string
14+
}
15+
16+
variable "public_key" {
17+
description = "Atlas API public key"
18+
type = string
19+
}
20+
21+
variable "private_key" {
22+
description = "Atlas API private key"
23+
type = string
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
version = "~> 1.38"
6+
}
7+
}
8+
required_version = ">= 1.0"
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# {{.Type}}: {{.Name}}
2+
3+
`{{.Name}}` provides a Cloud User Organization Assignment data source. The data source lets you retrieve a user assigned to an organization.
4+
5+
**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)
6+
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.
7+
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
8+
9+
## Example Usages
10+
11+
{{ tffile (printf "examples/%s/main.tf" .Name )}}
12+
13+
{{ .SchemaMarkdown | trimspace }}
14+
15+
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getorganizationuser) Documentation.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# {{.Type}}: {{.Name}}
2+
3+
`{{.Name}}` provides a Cloud User Organization Assignment resource. The resource lets you import, assign, remove, or update a user to an organization.
4+
5+
**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)
6+
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.
7+
To manage such users with this resource, refer to our [migration guide]<link-to-migration-guide>.
8+
9+
## Example Usages
10+
11+
{{ tffile (printf "examples/%s/main.tf" .Name )}}
12+
13+
{{ .SchemaMarkdown | trimspace }}
14+
15+
## Import
16+
17+
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`.
18+
19+
```
20+
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/[email protected]
21+
OR
22+
$ terraform import mongodbatlas_cloud_user_org_assignment.test 63cfbf302333a3011d98592e/5f18367ccb7a503a2b481b7a
23+
```
24+
25+
For more information see: [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createorganizationuser) Documentation.

0 commit comments

Comments
 (0)