hashicorp / hashicorp/terraform-plugin-framework
DiffSuppressFunc alternative?
- Dominant language
- Go
- Stars
- 384
- Forks
- 107
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
### Module version
```
v1.11.0
```
### Use-cases
To keep our plans less verbose, we'd like to be able to obscure/shorten the diff for some of our attributes on our resources.
### Attempted Solutions
1. Setting sensitive obscures the diff, but we want to obscure non-sensitive fields as well
2. I have attempted to use a plan modifier, but this impacts the value that gets applied to the state as well.
```go
"my_field": schema.StringAttribute{
...
Sensitive: true,
},
```
```go
type suppressFieldValue struct{}
func (m suppressFieldValue) Description(_ context.Context) string {
return "Suppresses the value within the plan"
}
func (m suppressFieldValue) MarkdownDescription(_ context.Context) string {
return "Suppresses the value within the plan"
}
func (m suppressFieldValue) PlanModifyString(
_ context.Context,
req planmodifier.StringRequest,
resp *planmodifier.StringResponse,
) {
resp.PlanValue = types.StringValue("<>")
}
```
### Proposal
We could have an optional value that, if set, overrides the diff of the attribute within the plan?
```go
...
func (m suppressFieldValue) PlanModifyString(
_ context.Context,
req planmodifier.StringRequest,
resp *planmodifier.StringResponse,
) {
resp.PlanDiffValue = types.StringValue("<>")
}
```
or just do something like: [DiffSuppressFunc from sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#diffsuppressfunc)
### References
- https://github.com/hashicorp/terraform-plugin-framework/issues/859
- https://discuss.hashicorp.com/t/diffsuppressfunc-alternative-in-terraform-framework/52578/5
- https://developer.hashicorp.com/terraform/plugin/framework/resources/plan-modification#creating-attribute-plan-modifiers
- https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#diffsuppressfunc
Contributor guide
Assessment
This issue has not been assessed yet.