I want to filter out cidr_block values in terraform

i have input as below

vpc_cidr_block = [
       [
           {
               association_id = "vpc-cidr-assoc"
               cidr_block     = "xx.xxx.xxx.xxx/24"
               state          = "associated"
            },
           {
               association_id = "vpc-cidr-assoc"
               cidr_block     = "xx.xxx.xxx.xxx/24"
               state          = "associated"
            },
           {
               association_id = "vpc-cidr-assoc"
               cidr_block     = "xx.xxx.xxx.xxx/23"
               state          = "associated"
            },
        ],
    ]

i want to filter out cidr_block values in terraform

Hi @dewshekhar,

I think you’re suggesting that you’d like to produce a new set of objects that still has association_id and state but does not include cidr_block. Here’s one way to achieve that:

locals {
  vpc_associations = [
    for o in var.vpc_cidr_block : {
      association_id = o.association_id
      state          = o.state
    }
  ]
}

If that isn’t the result you wanted, please show an example of what your intended result value should look like. Thanks!