Skip to content

Commit bfd8422

Browse files
csanxCristina Sánchez Sánchezcorryroot
authored
doc: Adds example & documentation for new mongodbatlas_team_project_assignment resource (#3581)
* Templates * Examples * Docs * Fix * Fix * Fixes * Changed example * Addressed comments * Apply suggestion from @corryroot Co-authored-by: corryroot <[email protected]> * Apply suggestion from @corryroot Co-authored-by: corryroot <[email protected]> * Updated docs --------- Co-authored-by: Cristina Sánchez Sánchez <[email protected]> Co-authored-by: corryroot <[email protected]>
1 parent 4dd1336 commit bfd8422

File tree

11 files changed

+187
-1
lines changed

11 files changed

+187
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Data Source: mongodbatlas_team_project_assignment
2+
3+
`mongodbatlas_team_project_assignment` provides a Team Project Assignment data source. The data source lets you retrieve a team assigned to a project.
4+
5+
## Example Usages
6+
7+
```terraform
8+
resource "mongodbatlas_team_project_assignment" "this" {
9+
project_id = var.project_id
10+
team_id = var.team_id
11+
role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"]
12+
}
13+
14+
data "mongodbatlas_team_project_assignment" "this" {
15+
project_id = mongodbatlas_team_project_assignment.this.project_id
16+
team_id = mongodbatlas_team_project_assignment.this.team_id
17+
}
18+
```
19+
20+
<!-- schema generated by tfplugindocs -->
21+
## Schema
22+
23+
### Required
24+
25+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-listprojects) endpoint to retrieve all projects to which the authenticated user has access.
26+
27+
**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.
28+
- `team_id` (String) Unique 24-hexadecimal character string that identifies the team.
29+
30+
### Read-Only
31+
32+
- `role_names` (Set of String) One or more project-level roles assigned to the team.
33+
34+
For more information, see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getprojectteam) Documentation.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Resource: mongodbatlas_team_project_assignment
2+
3+
`mongodbatlas_team_project_assignment` provides a Team Project Assignment resource. It lets you manage the association between a team and a project, enabling you to import, assign, remove, or update the team's membership.
4+
## Example Usages
5+
6+
```terraform
7+
resource "mongodbatlas_team_project_assignment" "this" {
8+
project_id = var.project_id
9+
team_id = var.team_id
10+
role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"]
11+
}
12+
13+
data "mongodbatlas_team_project_assignment" "this" {
14+
project_id = mongodbatlas_team_project_assignment.this.project_id
15+
team_id = mongodbatlas_team_project_assignment.this.team_id
16+
}
17+
```
18+
19+
<!-- schema generated by tfplugindocs -->
20+
## Schema
21+
22+
### Required
23+
24+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-listprojects) endpoint to retrieve all projects to which the authenticated user has access.
25+
26+
**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.
27+
- `role_names` (Set of String) One or more project-level roles assigned to the team.
28+
- `team_id` (String) Unique 24-hexadecimal character string that identifies the team.
29+
30+
## Import
31+
32+
Team Project Assignment resource can be imported using the Project ID & TeamID, in the format `PROJECT_ID/TEAM_ID`.
33+
34+
```
35+
$ terraform import mongodbatlas_team_project_assignment.test 9f3a7c2e54b8d1a0e6f4b3c2/a4d9f7b18e52c0fa36b7e9cd
36+
```
37+
38+
For more information, see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-addallteamstoproject) Documentation.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Example: mongodbatlas_team_project_assignment
2+
3+
This example demonstrates how to use the `mongodbatlas_team_project_assignment` resource to assign a team to an existing project 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_team_project_assignment" "this" {
14+
project_id = var.project_id
15+
team_id = var.team_id
16+
role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"]
17+
}
18+
19+
data "mongodbatlas_team_project_assignment" "this" {
20+
project_id = mongodbatlas_team_project_assignment.this.project_id
21+
team_id = mongodbatlas_team_project_assignment.this.team_id
22+
}
23+
```
24+
25+
You must set the following variables:
26+
27+
- `public_key`: Your MongoDB Atlas API public key.
28+
- `private_key`: Your MongoDB Atlas API private key.
29+
- `project_id`: The ID of the project to assign the team to.
30+
- `team_id`: The ID of the team to assign to the project.
31+
32+
To learn more, see the [MongoDB Atlas API - Cloud Users](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-addallteamstoproject) Documentation.
33+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resource "mongodbatlas_team_project_assignment" "this" {
2+
project_id = var.project_id
3+
team_id = var.team_id
4+
role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"]
5+
}
6+
7+
data "mongodbatlas_team_project_assignment" "this" {
8+
project_id = mongodbatlas_team_project_assignment.this.project_id
9+
team_id = mongodbatlas_team_project_assignment.this.team_id
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
output "assigned_team" {
2+
description = "Details of the assigned team"
3+
value = mongodbatlas_team_project_assignment.this
4+
}
5+
output "team_from_team_id" {
6+
description = "Project assignment details for the team retrieved by team_id"
7+
value = data.mongodbatlas_team_project_assignment.this
8+
}
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
variable "project_id" {
2+
description = "The MongoDB Atlas project ID"
3+
type = string
4+
}
5+
6+
variable "team_id" {
7+
description = "The MongoDB Atlas team ID"
8+
type = string
9+
}
10+
11+
variable "public_key" {
12+
description = "Atlas API public key"
13+
type = string
14+
default = ""
15+
}
16+
17+
variable "private_key" {
18+
description = "Atlas API private key"
19+
type = string
20+
default = ""
21+
}
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+
}

internal/service/teamprojectassignment/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func resourceSchema() schema.Schema {
1313
Attributes: map[string]schema.Attribute{
1414
"project_id": schema.StringAttribute{
1515
Required: true,
16-
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.",
16+
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-listprojects) endpoint to retrieve all projects to which the authenticated user has access.\n\n**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.",
1717
},
1818
"role_names": schema.SetAttribute{
1919
ElementType: types.StringType,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# {{.Type}}: {{.Name}}
2+
3+
`{{.Name}}` provides a Team Project Assignment data source. The data source lets you retrieve a team assigned to a project.
4+
5+
## Example Usages
6+
7+
{{ tffile (printf "examples/%s/main.tf" .Name )}}
8+
9+
{{ .SchemaMarkdown | trimspace }}
10+
11+
For more information, see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getprojectteam) Documentation.

0 commit comments

Comments
 (0)