-
Notifications
You must be signed in to change notification settings - Fork 91
/
requires_replace_if_configured.go
34 lines (29 loc) · 1.14 KB
/
requires_replace_if_configured.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package int64planmodifier
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
// RequiresReplaceIfConfigured returns a plan modifier that conditionally requires
// resource replacement if:
//
// - The resource is planned for update.
// - The plan and state values are not equal.
// - The configuration value is not null.
//
// Use RequiresReplace if the resource replacement should occur regardless of
// the presence of a configuration value. Use RequiresReplaceIf if the resource
// replacement should check provider-defined conditional logic.
func RequiresReplaceIfConfigured() planmodifier.Int64 {
return RequiresReplaceIf(
func(_ context.Context, req planmodifier.Int64Request, resp *RequiresReplaceIfFuncResponse) {
if req.ConfigValue.IsNull() {
return
}
resp.RequiresReplace = true
},
"If the value of this attribute is configured and changes, Terraform will destroy and recreate the resource.",
"If the value of this attribute is configured and changes, Terraform will destroy and recreate the resource.",
)
}