# \`TypeSet\` resource always want to destroy and recreate everything in set when one item has a diff

**URL:** <https://discuss.hashicorp.com/t/typeset-resource-always-want-to-destroy-and-recreate-everything-in-set-when-one-item-has-a-diff/54895>\
**Category:** Plugin Development\
**Created:** [June 12, 2023, 7:21pm UTC](https://discuss.hashicorp.com/t/typeset-resource-always-want-to-destroy-and-recreate-everything-in-set-when-one-item-has-a-diff/54895 "2023-06-12T19:21:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![teddylear](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/teddylear/32/36234_2.png) [@teddylear](https://discuss.hashicorp.com/u/teddylear)\
**Post date:** [June 12, 2023, 7:21pm UTC](https://discuss.hashicorp.com/t/typeset-resource-always-want-to-destroy-and-recreate-everything-in-set-when-one-item-has-a-diff/54895/1 "2023-06-12T19:21:28Z")

</div>

Recently I have noticed a few instances of TypeSet causing all resources in set to be destroyed and recreated when one item in the set has a difference. Is this intended behavior for `TypeSet`? Also, is there another resource that should be used to avoid this type of behavior? More details an an example of this can be found in [this github issue on terraform-plugin-sdk](https://github.com/hashicorp/terraform-plugin-sdk/issues/1210).

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [June 12, 2023, 9:17pm UTC](https://discuss.hashicorp.com/t/typeset-resource-always-want-to-destroy-and-recreate-everything-in-set-when-one-item-has-a-diff/54895/2 "2023-06-12T21:17:08Z")

</div>

> [@teddylear](#):
>
> causing all resources in set to be destroyed and recreated when one item in the set has a difference

That’s not what’s happening:

1. These are not resources, they are blocks within a resource.

2. They’re not **all** being destroyed and recreated - it’s just every element which has any changes is being removed, and new ones are being added.

This is expected behaviour - it’s how sets work. Since identity within sets is entirely defined by the value of the nested object, any change will be rendered as deletion of the old object, and addition of a new one.

It is worth noting that this is **only how Terraform displays the diff**. Whether the provider **actually** implements the change that way, or not, is entirely up to the provider code.

If you wanted Terraform to understand that an old entry and a new entry were related, and should be shown as a change, you need to use a list or map type, instead of a set.

---

<div class="post-metadata">

**Author:** ![teddylear](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/teddylear/32/36234_2.png) [@teddylear](https://discuss.hashicorp.com/u/teddylear)\
**Post date:** [June 12, 2023, 11:21pm UTC](https://discuss.hashicorp.com/t/typeset-resource-always-want-to-destroy-and-recreate-everything-in-set-when-one-item-has-a-diff/54895/3 "2023-06-12T23:21:24Z")

</div>

@maxb Thanks for the reply! I’ll try to update the to a `TypeList` or `TypeMap` then as part of the issue is the diff as well as only performing an update operation rather than recreating the policies.
