microsoft / terraform-provider-azuredevops

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

Creash when using data source azuredevops_serviceendpoint_azurecr #1179

Closed skarum closed 1 month ago

skarum commented 1 month ago

Community Note

Terraform (and Azure DevOps Provider) Version

Affected Resource(s)

Terraform Configuration Files

data "azuredevops_project" "this" {
  name = "projectname"
}

data "azuredevops_serviceendpoint_azurecr" "acr" {
  project_id          = data.azuredevops_project.this.id
  service_endpoint_name = "endpoint-name"
}

Debug Output

https://gist.github.com/skarum/3bb1502b668fde24fd438979ecbb83b7

Expected Behavior

Get the id of the service connectin

Actual Behavior

Plan crashes

Steps to Reproduce

  1. terraform plan

Important Factoids

I'm connecting to Azure DevOps with a PAT that have full access to service connections in that project - and I'm a project administrator.

image

I can add permissions to the service connection using an hardcoded service connection id.

Result is the same when using service_endpoint_id (with the id) and using service_endpoint_name (with the name)

xuzhang3 commented 1 month ago

@skarum can you help check that the the import resource is the ACR service connection? The scope in this service connection should in format of /subscriptions/<sub ID>/resourceGroups/<RG name>/providers/Microsoft.ContainerRegistry/registries/<Container register name> but it is not there in your scenario, so I guess it is not an Azure resource

skarum commented 1 month ago

You are right! I knew it was a connection to ACR, but had not checked how it was setup.

Turns out it was setup as "Others" in Docker Registry type

Image

Sorry about the confusion.