CiscoDevNet / terraform-provider-intersight

Cisco Intersight Terraform
Mozilla Public License 2.0
19 stars 25 forks source link

[ISSUE] Provider v1.0.56 data intersight_search_search_item ignoring additional_attributes for filter #300

Closed scotttyso closed 1 hour ago

scotttyso commented 2 hours ago

Bug Report Checklist

Description

For sometime I have been using additional_attributes with data intersight_search_search_item to filter, since there is no complex filter option. Noticed that going from v1.0.55 to v1.0.56 the additional_properties are now being ignored for the filter.

Using this workaround as proposed in this issue

Terraform-provider-intersight version

v1.0.56

Configuration file
data "intersight_search_search_item" "policies" {
  for_each = { for v in local.policy_types : v => v if length(compact(local.data_policies[v])) > 0 }
  additional_properties = jsonencode(
    { "ClassId" = "${local.bucket["${each.key}_policy"].object_type}' and Name in ('${trim(join("', '", local.data_policies[each.key]), ", '")
    }') and ObjectType eq '${local.bucket["${each.key}_policy"].object_type}" }
  )
}
Actual output (Attach screenshots if applicable)

I have the log and I can upload if you want but I can simply state that in 1.0.55 I see

GET /api/v1/search/SearchItems?%24count=true&%24filter=%28ClassId+eq+%27fabric.PortPolicy%27+and+Name+in+%28%27r143e-2-a%27%2C+%27r143e-2-b%27%29+and+ObjectType+eq+%27fabric.PortPolicy%27%29 HTTP/1.1 

and in 1.0.56 I see

GET /api/v1/search/SearchItems?%24filter=&%24skip=9200&%24top=100 HTTP/1.1
GET /api/v1/search/SearchItems?%24filter=&%24skip=9300&%24top=100 HTTP/1.1
GET /api/v1/search/SearchItems?%24filter=&%24skip=9400&%24top=100 HTTP/1.1
GET /api/v1/search/SearchItems?%24filter=&%24skip=9500&%24top=100 HTTP/1.1
GET /api/v1/search/SearchItems?%24filter=&%24skip=9600&%24top=100 HTTP/1.1 

as can be seen above it is going through every item in Intersight essentially.

Related issues/PRs
Suggest a fix
scotttyso commented 2 hours ago

I do have the DEBUG Log files for v1.0.55 and v1.0.56 for comparison if you want them but the .56 file is 25MB

scotttyso commented 1 hour ago

changing the order of ClassId and ObjectType works to work around this.