Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServicePrincipal ID: the number of segments didn't match #27570

Open
1 task done
thomasteoh opened this issue Oct 6, 2024 · 0 comments
Open
1 task done

ServicePrincipal ID: the number of segments didn't match #27570

thomasteoh opened this issue Oct 6, 2024 · 0 comments
Labels

Comments

@thomasteoh
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.9.7

AzureRM Provider Version

4.4.0

Affected Resource(s)/Data Source(s)

azurerm_service_principal, azurerm_service_principal_password

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "4.4.0"
    }
  }
}

# Configure the Microsoft Azure Provider
provider "azurerm" {
  resource_provider_registrations = "none" # This is only required when the User, Service Principal, or Identity running Terraform lacks the permissions to register Azure Resource Providers.
  features {}
  subscription_id = "<redacted>"
}

# Access configuration of the AzureRM provider
data "azurerm_client_config" "current" {
}

resource "azuread_application_registration" "ent_main" {
  display_name     = "Example Application"
  description      = "My example application"
  sign_in_audience = "AzureADMyOrg"

  homepage_url          = "https://app.hashitown.com/"
  logout_url            = "https://app.hashitown.com/logout"
  marketing_url         = "https://hashitown.com/"
  privacy_statement_url = "https://hashitown.com/privacy"
  support_url           = "https://support.hashitown.com/"
  terms_of_service_url  = "https://hashitown.com/terms"
}

data "azuread_application_published_app_ids" "well_known" {}

data "azuread_service_principal" "msgraph" {
  client_id = data.azuread_application_published_app_ids.well_known.result["MicrosoftGraph"]
}

resource "azuread_service_principal" "ent_main" {
  client_id    = azuread_application_registration.ent_main.client_id
  owners       = [data.azurerm_client_config.current.object_id]
  use_existing = true
}

resource "azuread_service_principal_password" "ent_main_secret" {
  service_principal_id = azuread_service_principal.ent_main.object_id
}

Debug Output/Panic Output

Error: parsing "2eadfd87-945c-4e78-bbbd-fed4496fb0d9": parsing the ServicePrincipal ID: the number of segments didn't match

│ Expected a ServicePrincipal ID that matched (containing 2 segments):

│ > /servicePrincipals/servicePrincipalId

│ However this value was provided (which was parsed into 0 segments):

│ > 2eadfd87-945c-4e78-bbbd-fed4496fb0d9

│ The following Segments are expected:

│ * Segment 0 - this should be the literal value "servicePrincipals"
│ * Segment 1 - this should be the user specified value for this servicePrincipalId [for example "servicePrincipalId"]

│ The following Segments were parsed:

│ * Segment 0 - not found
│ * Segment 1 - not found


│   with azuread_service_principal_password.ent_main_secret,
│   on temp.tf line 47, in resource "azuread_service_principal_password" "ent_main_secret":
│   47:   service_principal_id = azuread_service_principal.ent_main.object_id

Expected Behaviour

Either the ServicePrincipalId was produced with the number of segments expected by azuread_service_principal_password or the azuread_service_principal_password expects or handles just the objectid of the service principal

Actual Behaviour

Error, number of segments not matching

Steps to Reproduce

terraform apply

Important Factoids

No response

References

Possibly related to other issues from the SDK update #27461

@github-actions github-actions bot added the v/4.x label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant