hashicorp / terraform-provider-azuread

Terraform provider for Azure Active Directory
https://registry.terraform.io/providers/hashicorp/azuread/latest/docs
Mozilla Public License 2.0
417 stars 283 forks source link

data.azuread_service_principal field display_name incorrectly case sensitive #1345

Closed rsegers closed 2 months ago

rsegers commented 3 months ago

Community Note

Terraform (and AzureAD Provider) Version

Terraform v1.7.5
on windows_amd64
+ provider registry.terraform.io/hashicorp/azuread v2.47.0

Affected Resource(s)

Terraform Configuration Files

terraform {
  required_version = "~>1.7"

  required_providers {
    azuread = {
      source  = "hashicorp/azuread"
      version = "2.47.0"
    }
  }
  backend "local" {
    path = "./debug.tfstate"
  }
}

provider "azuread" {
  tenant_id = "xxxx"
}

data "azuread_service_principal" "msgraph" {
  display_name = "Microsoft GrapH" # note the capital H
}

Debug Output

The debug output shows a successful call to https://graph.microsoft.com/v1.0/servicePrincipals?%24filter=displayName+eq+%27Microsoft+GrapH The Graph result is exactly one service principal. Yet the azuread provider concludes No service principal found matching display name: \"Microsoft GrapH\"

https://gist.github.com/rsegers/6012f1106f36b1c184087b989ad3d5c1

Panic Output

Expected Behavior

It should fetch the service principal because display name should be case insensitive

Actual Behavior

│ Error: No service principal found matching display name: "Microsoft GrapH"
│
│   with data.azuread_service_principal.msgraph,
│   on main.tf line 26, in data "azuread_service_principal" "msgraph":
│   26: data "azuread_service_principal" "msgraph" {
│

Steps to Reproduce

  1. Create a data source for a service principal based on display_name with incorrect casing for the value

  2. terraform plan

Important Factoids

References

manicminer commented 2 months ago

Thanks for reporting @rsegers, I've opened #1381 to fix this 👍