Two-dimensional TypeList/TypeSet

Is there any way, when using the framework, to get an attribute that can contain a two-dimensional List or Set as below? With a small caveat - no nested named elements.

  mounts_list = [
    ["my_alias.1", "/mnt1"],
    ["my_alias.2", "/mnt2"],

Rather than thinking of this as a single two-dimensional data type, this would ideally be represented as a list of tuples.

The problem with that is that terraform-plugin-framework is missing support for tuples.

You could represent it as a list of lists of strings, if you wanted to. But it might be more idiomatic, and self-documenting, to change the representation to a list of objects:

  mounts_list = [
    { alias = "my_alias.1", path = "/mnt1" },
    { alias = "my_alias.2", path = "/mnt2" },

Hi @vaerh,

You can create a two-dimensional List or Set by defining a ListAttribute or SetAttribute with a ListType or SetType as the ElementType:

"list_list_attribute": schema.ListAttribute{
    Optional: true,
	ElementType: types.ListType{
		ElemType: types.StringType,

Although you can do this, it’s preferable to use a ListNestedAttribute or SetNestedAttribute with nested named elements if at all possible.

1 Like

Thanks for the suggestion, but I needed to avoid named attributes.

This is great and just what I need!
Thanks, I spent a lot of time experimenting yesterday and didn’t get that simplicity. :wink: