terraform-provider-googleworkspace icon indicating copy to clipboard operation
terraform-provider-googleworkspace copied to clipboard

Impossible to query root org unit by path using the googleworkspace_org_unit data source

Open tasansga opened this issue 1 year ago • 0 comments

Terraform Version

Noticed on 1.3.4, also exists on 1.4.4

Affected Resource(s)

  • data.googleworkspace_org_unit

Terraform Configuration Files

data "googleworkspace_org_unit" "root" {
  org_unit_path = "/"
}

output "root" {
  value = data.googleworkspace_org_unit.root
}

Debug Output

terraform plan yields:

+ root = {
  + block_inheritance    = null
  + description          = null
  + etag                 = null
  + id                   = null
  + name                 = null
  + org_unit_id          = null
  + org_unit_path        = null
  + parent_org_unit_id   = null
  + parent_org_unit_path = null
+ }

Expected Behavior

The data source should've either returned a NOT FOUND error or the org unit with correct values. (Note, fetching the root org unit by id does yield correct values.)

Actual Behavior

The data source returned empty values.

Steps to Reproduce

Define data source and output

data "googleworkspace_org_unit" "root" {
  org_unit_path = "/"
}

output "root" {
  value = data.googleworkspace_org_unit.root
}

and run terraform plan.

Note, this also happens with empty string and double slash "//" as org unit path, presumably because https://github.com/hashicorp/terraform-provider-googleworkspace/blob/0989f1a745380593cbf900f30fea0ba048bacae5/internal/provider/data_source_org_unit.go#L50 leads to the result always being the empty string.

tasansga avatar Mar 31 '23 07:03 tasansga