microsoft / terraform-provider-azuredevops

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

azuredevops_securityrole_assignment doesn't detect missing permissions correctly #1102

Closed drdamour closed 3 months ago

drdamour commented 4 months ago

Community Note

Terraform (and Azure DevOps Provider) Version

Affected Resource(s)

Terraform Configuration Files

resource "azuredevops_project" "example" {
  name               = "Example Project"
  visibility         = "private"
  version_control    = "Git"
  work_item_template = "Agile"
  description        = "Managed by Terraform"
}

resource "azuredevops_group" "example" {
  scope        = azuredevops_project.example.id
  display_name = "Example group"
  description  = "Description of example group"
}

resource "azuredevops_securityrole_assignment" "example" {
  scope       = "distributedtask.globalenvironmentreferencerole"
  resource_id = azuredevops_project.appd.id
  identity_id = azuredevops_group.example.origin_id
  role_name   = "User"
}

Debug Output

Panic Output

Expected Behavior

After applying this successfully, i went into web gui and delete this permissions.

I expected a subsequent apply to detect that this permissions was no longer present and show in plan trying to set it back

also i expected if i removed the resource "azuredevops_securityrole_assignment" "example" block after manual deleting for the plan to come back clean / show no changes necessary

Actual Behavior

subsequent apply showed that there were no change needed

when removing the resource "azuredevops_securityrole_assignment" "example" block from .tf file, the plan showed it needed to delete the resource

it was kinda like it was reading the current values from state and NOT from the response from azdo http services.

Steps to Reproduce

  1. terraform apply

Important Factoids

sniffing the traffic i was able to confirm GET https://dev.azure.com//_apis/securityroles/scopes/distributedtask.globalenvironmentreferencerole/roleassignments/resources/ did NOT return the assignment in the list..so azdo was giving back good info..seems like provider wasn't using it

References