hashicorp / hashicorp/terraform-plugin-framework
Describe how to use resource plan modification for a resource that cannot be updated
- Dominant language
- Go
- Stars
- 384
- Forks
- 107
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
### Module version
```
1.4.2
```
### Use-cases
For resources that have no update functionality rather than adding the [resource.RequiresReplace() attribute plan modifier](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource#RequiresReplace) in the schema, you would like to use [resource plan modification](https://developer.hashicorp.com/terraform/plugin/framework/resources/plan-modification). Based on the documentation it is, however, not clear for first-time Terraform plugin developers how to achieve this.
### Attempted Solutions
```go
func (r * ThingResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
var state ThingResourceceModel
readDiags := req.State.Get(ctx, &state)
resp.Diagnostics.Append(readDiags...)
if resp.Diagnostics.HasError() {
return
}
resp.RequiresReplace(path.Paths{path.Root("field?")})
```
### Proposal
Would it be possible to explain how to achieve this? If I know this then I dont mind extending the docs on for example the [update resource page](https://developer.hashicorp.com/terraform/plugin/framework/resources/update)
### References
Contributor guide
Assessment
This issue has not been assessed yet.