microsoft / terraform-provider-azuredevops

Terraform Azure DevOps provider
https://www.terraform.io/docs/providers/azuredevops/
MIT License
372 stars 260 forks source link

Azure DevOps Service Connection: Share service connection with other projects #1031

Open mateustanaka opened 2 months ago

mateustanaka commented 2 months ago

Community Note

Description

Share and unshare a service connection with other projects.

New or Affected Resource(s)

serviceendpoint_id - (Required) Endpoint Id of the service connection to share project_reference - (Required) A list of project_reference block as defined below. Objects describing which projects the service connection will be shared An project_reference block supports the following:

  • project_id - (Required) Project id which service endpoint will be shared
  • service_endpoint_name - (Optional) Name for service connection in the shared project. Default keep the same name
  • description - (Optional) Description for service connection in the shared project. Default keep the same description

Potential Terraform Configuration

resource "azuredevops_serviceendpoint_project_permissions" "example-share" {
  serviceendpoint_id = azuredevops_serviceendpoint_azurerm.example.id

  project_reference = {
    project_id            = azuredevops_project.example_one.id
    service_endpoint_name = "service-connection-shared"
    description           = "Service Connection Shared by Terraform - Cluster One"
  }

  project_reference = {
    project_id            = azuredevops_project.example_two.id
    service_endpoint_name = "service-connection-shared"
    description           = "Service Connection Shared by Terraform - Cluster Two"
  }
}

References

mouismail commented 1 month ago

πŸ‘‹ I can work on this one using the following plan:

Introduce resources_serviceendpoint_permissions.go

Please if this plan works for you, I can move forward and start working on it.

mateustanaka commented 1 month ago

πŸ‘‹ I can work on this one using the following plan:

Introduce resources_serviceendpoint_permissions.go

  • [ ] Add support for azuredevops_serviceendpoint_project_permissions resource
  • [ ] Implement CRUD operations for the resource
  • [ ] Handle project_reference blocks within the resource
  • [ ] Implement logic to share service connections with specified projects
  • [ ] Add optional service_endpoint_name and description handling for shared projects
  • [ ] Implement Unit tests resources_serviceendpoint_permissions_test.go
  • [ ] Update documentation to include azuredevops_serviceendpoint_project_permissions resource
  • [ ] Document project_reference block usage
  • [ ] Provide examples for sharing service connections with multiple projects

Please if this plan works for you, I can move forward and start working on it.

Hi @mouismail the plan is good for me, I really appreciate it!

mouismail commented 1 month ago

@mateustanaka awesome, I will open a PR soon for it

icehanyou commented 1 month ago

Would it be a similar solution for agent pools aswell maybe?