# Set of SetNestedAttributes or MapNestedAttribute

**URL:** <https://discuss.hashicorp.com/t/set-of-setnestedattributes-or-mapnestedattribute/75355>\
**Category:** Plugin Development\
**Created:** [June 7, 2025, 11:48am UTC](https://discuss.hashicorp.com/t/set-of-setnestedattributes-or-mapnestedattribute/75355 "2025-06-07T11:48:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![np5](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/np5/32/45849_2.png) [@np5](https://discuss.hashicorp.com/u/np5)\
**Post date:** [June 7, 2025, 11:48am UTC](https://discuss.hashicorp.com/t/set-of-setnestedattributes-or-mapnestedattribute/75355/1 "2025-06-07T11:48:01Z")

</div>

I have to build a resource that has an attribute that is a set of sets of objects or a set of maps of objects. Ideally, it would look like:

```auto
resource "my_resource" "slug" {
  filters_v1 = [
    [
      { attribute = "decision", operator = "IN", values = ["un"] },
      { attribute = "process", operator = "NOT_IN", values = ["one", "two"] },
    ],
    [
      { attribute = "decision", operator = "IN", values = ["deux"] },
      { attribute = "process", operator = "NOT_IN", values = ["three"] },
    ],
  ]
}

```

or with some compromises

```auto
resource "my_resource" "slug" {
  filters_v2 = [
    {
      "decision" = { operation = "IN", values = ["un"] },
      "process" = { operation = "NOT_IN", values = ["one", "two"] }
    },
    {
      "decision" = { operation = "IN", values = ["deux"] },
      "process" = { operation = "NOT_IN", values = ["three"] }
    },
  ]
}

```

Can it be built with `SetNestedAttribute` or `MapNestedAttribute` without using a custom type? I am stuck because of the top level set.

---

<div class="post-metadata">

**Author:** ![austin.valle](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/austin.valle/32/33332_2.png) [@austin.valle](https://discuss.hashicorp.com/u/austin.valle)\
**Post date:** [June 9, 2025, 1:32pm UTC](https://discuss.hashicorp.com/t/set-of-setnestedattributes-or-mapnestedattribute/75355/2 "2025-06-09T13:32:40Z")

</div>

`SetNestedAttribute` is always a `set of objects` (similar for map and the other nested attributes, it’s [defined at the protocol level](https://github.com/hashicorp/terraform-plugin-go/blob/c369cdc8bb8deb4e577b5453c28dc1a9d15f9375/tfprotov6/internal/tfplugin6/tfplugin6.proto#L105)), so any representation of a multi dimensional collection will have to use [`SetAttribute`](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes/set) or [`MapAttribute`](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes/map), along with the expected element type:

```go
"filters_v1": schema.SetAttribute{
    ElementType: types.SetType{
        ElemType: types.ObjectType{/* filter attr types */},
    },
    Required: true,
    // ... other fields ...
},

```

---

<div class="post-metadata">

**Author:** ![np5](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/np5/32/45849_2.png) [@np5](https://discuss.hashicorp.com/u/np5)\
**Post date:** [June 10, 2025, 12:18pm UTC](https://discuss.hashicorp.com/t/set-of-setnestedattributes-or-mapnestedattribute/75355/3 "2025-06-10T12:18:43Z")

</div>

Thanks a lot for your help. It works.

What is the recommended way to generate the docs for this attribute ?

---

<div class="post-metadata">

**Author:** ![austin.valle](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/austin.valle/32/33332_2.png) [@austin.valle](https://discuss.hashicorp.com/u/austin.valle)\
**Post date:** [June 10, 2025, 2:32pm UTC](https://discuss.hashicorp.com/t/set-of-setnestedattributes-or-mapnestedattribute/75355/4 "2025-06-10T14:32:03Z")

</div>

Since it can’t be a nested attribute, there isn’t a way to attach any additional metadata to the nested objects or it’s attributes (like required/optional/computed, or documentation fields like description) in a way that Terraform (or downstream tools) can actually read → [Consider Exposing Framework Provider Metadata · Issue #1022 · hashicorp/terraform-plugin-framework · GitHub](https://github.com/hashicorp/terraform-plugin-framework/issues/1022)

So unfortunately the only real option you have is to write the documentation manually, which if you’re using something like `terraform-plugin-docs`, you can do that with [templates](https://github.com/hashicorp/terraform-plugin-docs?tab=readme-ov-file#conventional-paths) like:

- [terraform-provider-time/templates/functions/rfc3339\_parse.md.tmpl at 76e6faf8ce8ea388b2a342bd069d71368803f4de · hashicorp/terraform-provider-time · GitHub](https://github.com/hashicorp/terraform-provider-time/blob/76e6faf8ce8ea388b2a342bd069d71368803f4de/templates/functions/rfc3339_parse.md.tmpl#L31-L44)
