Issue: Accessing Nested Variables inside Nested Dynamic Block

Error: Invalid value for input variable

│ on xray-watches.tf line 10, in module “xray-project-watch-devops-platform”:
│ 10: watch_resources = [{ # all repo
│ 11: filter = [{}]
│ 12: }]

│ The given value is not suitable for module.xray-project-watch-devops-platform.var.watch_resources declared at modules/xray/watch/variables.tf:22,1-27: object required.


main.tf

terraform {
required_providers {
xray = {
source = “Terraform Registry
version = “1.14.0”
}
}
}

resource “xray_watch” “this” {
name = var.name
description = var.description
active = true
project_key = var.project_key

dynamic “watch_resource” {
for_each = var.watch_resources
content {
type = watch_resource.value.type
bin_mgr_id = watch_resource.value.bin_mgr_id
name = watch_resource.value.name
repo_type = watch_resource.value.repo_type

  dynamic "filter" {
    for_each = watch_resource.value["filter"] != {} ? [1] : []
    content {
      type  = filter.value["type"]
      value = filter.value["value"]
    }
  }
}

}

dynamic “assigned_policy” {
for_each = var.assigned_policies
content {
name = assigned_policy.value.name
type = assigned_policy.value.type
}
}
}


variables.tf

variable “name” {
type = string
description = “Name of the watch”
default = “xray-watch”
}

variable “description” {
type = string
default = “”
}

variable “active” {
type = bool
default = true
}

variable “project_key” {
type = string
default = “”
}

variable “watch_resources” {
description = “List of watch resources”
type = object({
type = optional(string, “all-repos”)
bin_mgr_id = optional(string, “default”)
name = optional(string, null)
repo_type = optional(string, null) //Can be local/remote. Only applicable when type is repository

filter = object({
  type  = optional(string, "regex")
  value = optional(string, ".*")
})

})
}

variable “assigned_policies” {
description = “Name and type of policy attached to the watch”
type = list(object({
name = string
type = string
}))
}