Open MathKlim opened 8 months ago
@MathKlim What permissions does the PAT assigned? It appears that the PAT used to create the service connection does not have enough permissions.
@MathKlim You're using; azuread_service_principal.current.client_id
for the azurecr_spn_tenantid
try;
azuread_service_principal.current.application_tenant_id
PS. I'd be interested to know what API Permissions you're executing Service Principal has? We are currently facing a similar issue, I've granted the executing Service Principal 'Owner' Rights on Resource Group containing the Container Registry - But the Service Principal also need's permission in Entra so it can create and manage the Service Principal used by the Service Endpoint - Not currently playing ball!
Community Note
Hi, I'm trying to automate the creation of an azurecr service connection, but I'm not able to.
Terraform (and Azure DevOps Provider) Version
Terraform v1.7.3 on linux_amd64
provider registry.terraform.io/microsoft/azuredevops v0.11.0
provider registry.terraform.io/hashicorp/azuread v2.47.0
provider registry.terraform.io/hashicorp/azurerm v3.92.0
provider registry.terraform.io/hashicorp/random v3.6.0
Affected Resource(s)
azuredevops_serviceendpoint_azurecr
Terraform Configuration Files
Debug Output
https://gist.github.com/MathKlim/e997047a9cbbfa061dc8c7864b8b9b80
I do get the following error in the terminal.
β Error: waiting for service endpoint ready. Error looking up service endpoint given ID (32d963ca-8d13-4a25-818f-8e4447f66905) and project ID (d7fff28e-369e-4233-bedf-2eab9f303cd2): map[severity: state:Failed statusMessage:HandleMsalServiceExceptionFromRefreshTokenUse: Failed to obtain an access token of identity dd2bdf7b-482d-7dd1-b821-b298fc1f9d28 using cached refresh token. Sign-in required.]
β β with azuredevops_serviceendpoint_azurecr.current, β on main.tf line 88, in resource "azuredevops_serviceendpoint_azurecr" "current": β 88: resource "azuredevops_serviceendpoint_azurecr" "current" {
Expected Behavior
The service connection should be created.
Actual Behavior
Everything is created but the service connection.
Steps to Reproduce
terraform apply
Important Factoids
Where did I miss something ?
References
0000