Conditional Blocks for Terraform resource creation

I am trying to create some lb rules using the following resource : https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener_rule

I am trying to iterate over a map of objects and create these rules, some of which have have different condition blocks but even though the resources states these are optional it doesn't like null as a value

I am wondering if it is possible to only add a condition based on the object passed in

condition {
    path_pattern {
      values = each.value.condition_block.path_patterns
    }
  }

  condition {
    host_header {
      values = each.value.condition_block.host_headers
    }
  }

so in the above example some of my config might not have a path_pattern set in which casa I would want it to skip over this and just add the host_header values and so on.

I did try doing this

condition {
        path_pattern {
          values = try(each.value.condition_block.path_patterns, null)
        }
      }

but it doesn't like this

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum