Dynamic block help

Hi there, I am seeking some help on passing values into my dynamic block via a module. My structure looks like the following.

env.tfvars

services = {

  my_new_service = {
    services_title   = "My title"
    services_enabled = true
    services_rule = [
      {
        field      = "role",
        field_type = "info",
        rule_type  = "matches",
        value      = "My Value"
      }
    ]
    services_kpi = [
      {
        title              = "Free space % C",
        base_search_id     = "OS:Performance_LogicalDisk_win",
        base_search_metric = "Free space % C"
      },
      {
        title              = "Free space % M",
        base_search_id     = "OS:Performance_LogicalDisk_win",
        base_search_metric = "Free space % M"
      },
      {
        title              = "CPU Idle %",
        base_search_id     = "OS:Performance_CPU_Idle_win",
        base_search_metric = "CPU Idle %"
      },
    ]
  }

}

main.tf

module "services" {
  for_each = var.services
  source   = "../../modules/itsi/services"

  services_title          = each.value["services_title"]
  services_enabled        = try(each.value["services_enabled"], false)
  services_rule           = each.value["services_rule"]
  services_kpi            = each.value["services_kpi"]  
  services_security_group = try(each.value["services_security_group"], "default_itsi_security_group")

}

variables.tf (services module. I left out the other variables, this is just the one I am having issues with.)

....

variable "services_kpi" {
  description = "A set of rule groups that are combined by OR operator"
  type = list(object({
    title                         = string
    base_search_id     = string
    base_search_metric = string
  }))
}

main.tf (services module)

resource "itsi_service" "services" {
  title   = var.services_title
  enabled = var.services_enabled
  entity_rules {

    dynamic "rule" {
      for_each = var.services_rule
      iterator = item
      content {
        field      = item.value.field
        field_type = item.value.field_type
        rule_type  = item.value.rule_type
        value      = item.value.value
      }

    }

  }

  dynamic "kpi" {

    for_each = var.services_kpi
    iterator = item
    content {
      title              = item.value.title
      base_search_id     = data.itsi_kpi_base_search.title.id
      base_search_metric = item.value.base_search_metric
    }
  }

  security_group = var.services_security_group
}

The issue I am having is with “base_search_id” inside the dynamic kpi block. What I am trying to do is, the value from my env.tfvars file is a title name, I need that title name to be converted to the guid number which is what the data block is responsible for, it takes the title name and gets the guid id for it.

The problem that I dont know how to solve is that it assigns the same guid id to all the base_search_id, below is my tfstate file.

Any ideas how I can pass in the correct base_search_id for each title into the dynamic block based on the title I have sent into the module?

            "kpi": [
              {
                **"base_search_id": "5ac77f4e-bacd-b685-7fc3-ec040da228b0",**
                "base_search_metric": "CPU Idle %",
                "custom_threshold": [],
                "id": "e64d933e-d05c-96c6-2b71-8d052639c1e6",
                "search_type": "shared_base",
                "threshold_template_id": "",
                "title": "CPU Idle %",
                "type": "kpis_primary",
                "urgency": 5
              },
              {
                **"base_search_id": "5ac77f4e-bacd-b685-7fc3-ec040da228b0",**
                "base_search_metric": "Free space % C",
                "custom_threshold": [],
                "id": "1aeeadff-db5b-aad2-f963-4853c65cc7ef",
                "search_type": "shared_base",
                "threshold_template_id": "",
                "title": "Free space % C",
                "type": "kpis_primary",
                "urgency": 5
              },
              {
                **"base_search_id": "5ac77f4e-bacd-b685-7fc3-ec040da228b0",**
                "base_search_metric": "Free space % M",
                "custom_threshold": [],
                "id": "576fa768-e0a7-ac57-cedf-bc81e64c28b2",
                "search_type": "shared_base",
                "threshold_template_id": "",
                "title": "Free space % M",
                "type": "kpis_primary",
                "urgency": 5
              }