terraform-plugin-framework icon indicating copy to clipboard operation
terraform-plugin-framework copied to clipboard

Add plan modification support to `attr.Type`

Open paddycarver opened this issue 4 years ago • 0 comments

Module version

main@b0e3081ddbdab74c40ed0def9b8c23816a93d8fe

Use-cases

Several types have semantically equivalent representations that are not byte-for-byte equivalent like Terraform requires. A JSON type comes to mind, in which

{
  "key": "value"
}

and

{"key": "value"}

should be considered equal, but Terraform treats as distinct values. By allowing plan modification strategies to be associated with attr.Types, we can make sure this behavior is applied consistently everywhere the type is used.

Attempted Solutions

We can work around this by adding an AttributePlanModifier to each schema.Attribute, but that requires consistency and extra work for provider developers that can be avoided.

Proposal

Similar to attr.TypeWithValidate we create an attr.TypeWithModifyPlan that allows defining plan modification for the type. This plan modification runs before attribute plan modification and before whole resource plan modification.

paddycarver avatar Sep 15 '21 12:09 paddycarver