diff --git a/docs/data-sources/team_project_assignment.md b/docs/data-sources/team_project_assignment.md new file mode 100644 index 0000000000..b56e724549 --- /dev/null +++ b/docs/data-sources/team_project_assignment.md @@ -0,0 +1,34 @@ +# Data Source: mongodbatlas_team_project_assignment + +`mongodbatlas_team_project_assignment` provides a Team Project Assignment data source. The data source lets you retrieve a team assigned to a project. + +## Example Usages + +```terraform +resource "mongodbatlas_team_project_assignment" "this" { + project_id = var.project_id + team_id = var.team_id + role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"] +} + +data "mongodbatlas_team_project_assignment" "this" { + project_id = mongodbatlas_team_project_assignment.this.project_id + team_id = mongodbatlas_team_project_assignment.this.team_id +} +``` + + +## Schema + +### Required + +- `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. + +**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. +- `team_id` (String) Unique 24-hexadecimal character string that identifies the team. + +### Read-Only + +- `role_names` (Set of String) One or more project-level roles assigned to the team. + +For more information see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getprojectteam) Documentation. diff --git a/docs/resources/team_project_assignment.md b/docs/resources/team_project_assignment.md new file mode 100644 index 0000000000..376c5c51c6 --- /dev/null +++ b/docs/resources/team_project_assignment.md @@ -0,0 +1,38 @@ +# Resource: mongodbatlas_team_project_assignment + +`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. +## Example Usages + +```terraform +resource "mongodbatlas_team_project_assignment" "this" { + project_id = var.project_id + team_id = var.team_id + role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"] +} + +data "mongodbatlas_team_project_assignment" "this" { + project_id = mongodbatlas_team_project_assignment.this.project_id + team_id = mongodbatlas_team_project_assignment.this.team_id +} +``` + + +## Schema + +### Required + +- `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. + +**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. +- `role_names` (Set of String) One or more project-level roles assigned to the team. +- `team_id` (String) Unique 24-hexadecimal character string that identifies the team. + +## Import + +Team Project Assignment resource can be imported using the Project ID & TeamID, in the format `PROJECT_ID/TEAM_ID`. + +``` +$ terraform import mongodbatlas_team_project_assignment.test 9f3a7c2e54b8d1a0e6f4b3c2/a4d9f7b18e52c0fa36b7e9cd +``` + +For more information see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-addallteamstoproject) Documentation. diff --git a/examples/mongodbatlas_team_project_assignment/README.md b/examples/mongodbatlas_team_project_assignment/README.md new file mode 100644 index 0000000000..7aa41cad00 --- /dev/null +++ b/examples/mongodbatlas_team_project_assignment/README.md @@ -0,0 +1,33 @@ +# Example: mongodbatlas_team_project_assignment + +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. + +## Usage + +```hcl +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} + +resource "mongodbatlas_team_project_assignment" "this" { + project_id = var.project_id + team_id = var.team_id + role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"] +} + +data "mongodbatlas_team_project_assignment" "this" { + project_id = mongodbatlas_team_project_assignment.this.project_id + team_id = mongodbatlas_team_project_assignment.this.team_id +} +``` + +You must set the following variables: + +- `public_key`: Your MongoDB Atlas API public key. +- `private_key`: Your MongoDB Atlas API private key. +- `project_id`: The ID of the project to assign the team to. +- `team_id`: The ID of the team to assign to the project. + +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. + diff --git a/examples/mongodbatlas_team_project_assignment/main.tf b/examples/mongodbatlas_team_project_assignment/main.tf new file mode 100644 index 0000000000..d5857cc09a --- /dev/null +++ b/examples/mongodbatlas_team_project_assignment/main.tf @@ -0,0 +1,10 @@ +resource "mongodbatlas_team_project_assignment" "this" { + project_id = var.project_id + team_id = var.team_id + role_names = ["GROUP_OWNER", "GROUP_DATA_ACCESS_ADMIN"] +} + +data "mongodbatlas_team_project_assignment" "this" { + project_id = mongodbatlas_team_project_assignment.this.project_id + team_id = mongodbatlas_team_project_assignment.this.team_id +} diff --git a/examples/mongodbatlas_team_project_assignment/outputs.tf b/examples/mongodbatlas_team_project_assignment/outputs.tf new file mode 100644 index 0000000000..e64544f041 --- /dev/null +++ b/examples/mongodbatlas_team_project_assignment/outputs.tf @@ -0,0 +1,8 @@ +output "assigned_team" { + description = "Details of the assigned team" + value = mongodbatlas_team_project_assignment.this +} +output "team_from_team_id" { + description = "Project assignment details for the team retrieved by team_id" + value = data.mongodbatlas_team_project_assignment.this +} diff --git a/examples/mongodbatlas_team_project_assignment/provider.tf b/examples/mongodbatlas_team_project_assignment/provider.tf new file mode 100644 index 0000000000..18c430e061 --- /dev/null +++ b/examples/mongodbatlas_team_project_assignment/provider.tf @@ -0,0 +1,4 @@ +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} diff --git a/examples/mongodbatlas_team_project_assignment/variables.tf b/examples/mongodbatlas_team_project_assignment/variables.tf new file mode 100644 index 0000000000..e439259fea --- /dev/null +++ b/examples/mongodbatlas_team_project_assignment/variables.tf @@ -0,0 +1,21 @@ +variable "project_id" { + description = "The MongoDB Atlas project ID" + type = string +} + +variable "team_id" { + description = "The MongoDB Atlas team ID" + type = string +} + +variable "public_key" { + description = "Atlas API public key" + type = string + default = "" +} + +variable "private_key" { + description = "Atlas API private key" + type = string + default = "" +} diff --git a/examples/mongodbatlas_team_project_assignment/versions.tf b/examples/mongodbatlas_team_project_assignment/versions.tf new file mode 100644 index 0000000000..905429b750 --- /dev/null +++ b/examples/mongodbatlas_team_project_assignment/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + mongodbatlas = { + source = "mongodb/mongodbatlas" + version = "~> 1.38" + } + } + required_version = ">= 1.0" +} diff --git a/internal/service/teamprojectassignment/schema.go b/internal/service/teamprojectassignment/schema.go index f8b7fc6488..0d686b8705 100644 --- a/internal/service/teamprojectassignment/schema.go +++ b/internal/service/teamprojectassignment/schema.go @@ -13,7 +13,7 @@ func resourceSchema() schema.Schema { Attributes: map[string]schema.Attribute{ "project_id": schema.StringAttribute{ Required: true, - 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.", + 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.", }, "role_names": schema.SetAttribute{ ElementType: types.StringType, diff --git a/templates/data-sources/team_project_assignment.md.tmpl b/templates/data-sources/team_project_assignment.md.tmpl new file mode 100644 index 0000000000..8d6cb1cc99 --- /dev/null +++ b/templates/data-sources/team_project_assignment.md.tmpl @@ -0,0 +1,11 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` provides a Team Project Assignment data source. The data source lets you retrieve a team assigned to a project. + +## Example Usages + +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +For more information see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getprojectteam) Documentation. diff --git a/templates/resources/team_project_assignment.md.tmpl b/templates/resources/team_project_assignment.md.tmpl new file mode 100644 index 0000000000..34a4106361 --- /dev/null +++ b/templates/resources/team_project_assignment.md.tmpl @@ -0,0 +1,18 @@ +# {{.Type}}: {{.Name}} + +`{{.Name}}` 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. +## Example Usages + +{{ tffile (printf "examples/%s/main.tf" .Name )}} + +{{ .SchemaMarkdown | trimspace }} + +## Import + +Team Project Assignment resource can be imported using the Project ID & TeamID, in the format `PROJECT_ID/TEAM_ID`. + +``` +$ terraform import mongodbatlas_team_project_assignment.test 9f3a7c2e54b8d1a0e6f4b3c2/a4d9f7b18e52c0fa36b7e9cd +``` + +For more information see: [MongoDB Atlas API - Teams](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-addallteamstoproject) Documentation.