When to use nested block Vs nested attribute

I’m migrating an existing provider from the v2 SDK to the new framework and i have been trying to use a nested block so the interface matches the existing provider interface, but have had issues (see currently unanswered questions here: How to compare changes for nested block with new framework? and How to convert concrete tftypes.Value to something that implements attr.Value).

I’m thinking if I don’t get any help on those other two questions then I’ll consider moving to a nested attribute which looks to be easier to deal with but I’m wondering what are the fundamental differences between nested blocks and nested attributes?

Why would I choose one over the other?


Current advice is to only use nested blocks to support compatibility with existing resource types that already have code written using them. (Or, if for some mad reason, you’re still writing new code which still needs to support Terraform 0.x.)

Plugin Development - Framework: Handling Data - Blocks | Terraform | HashiCorp Developer :

Use nested attributes for new schema implementations. Block support is mainly for migrating prior SDK-based providers.

There’s a lot of historical reasons that led to this point.

Can you share the schema of the existing interface you’re working with?