Skip to content

Commit 7cdb720

Browse files
authored
feat(networks,connections): add replace updates (#15)
* feat(networks,connections): add replace updates * remove manual udpates
1 parent b0ef2e8 commit 7cdb720

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

internal/provider/connection.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import (
44
"context"
55
"time"
66

7-
dfcloud "github.com/dragonflydb/terraform-provider-dfcloud/internal/sdk"
87
"github.com/dragonflydb/terraform-provider-dfcloud/internal/resource_model"
8+
dfcloud "github.com/dragonflydb/terraform-provider-dfcloud/internal/sdk"
99
"github.com/hashicorp/terraform-plugin-framework/resource"
1010
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
11+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
12+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
13+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1114
"github.com/hashicorp/terraform-plugin-framework/types"
1215
)
1316

@@ -26,6 +29,7 @@ func (r *ConnectionResource) Metadata(ctx context.Context, req resource.Metadata
2629
func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
2730
resp.Schema = schema.Schema{
2831
MarkdownDescription: "Manages a Dragonfly network connection.",
32+
2933
Attributes: map[string]schema.Attribute{
3034
"connection_id": schema.StringAttribute{
3135
MarkdownDescription: "The ID of the connection.",
@@ -46,10 +50,16 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ
4650
"name": schema.StringAttribute{
4751
MarkdownDescription: "The name of the connection.",
4852
Required: true,
53+
PlanModifiers: []planmodifier.String{
54+
stringplanmodifier.RequiresReplace(),
55+
},
4956
},
5057
"network_id": schema.StringAttribute{
5158
MarkdownDescription: "The ID of the network to connect to.",
5259
Required: true,
60+
PlanModifiers: []planmodifier.String{
61+
stringplanmodifier.RequiresReplace(),
62+
},
5363
},
5464
"peer": schema.SingleNestedAttribute{
5565
MarkdownDescription: "The VPC to connect to.",
@@ -68,6 +78,9 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ
6878
Optional: true,
6979
},
7080
},
81+
PlanModifiers: []planmodifier.Object{
82+
objectplanmodifier.RequiresReplace(),
83+
},
7184
},
7285
},
7386
}

internal/provider/network.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import (
44
"context"
55
"time"
66

7-
dfcloud "github.com/dragonflydb/terraform-provider-dfcloud/internal/sdk"
87
"github.com/dragonflydb/terraform-provider-dfcloud/internal/resource_model"
8+
dfcloud "github.com/dragonflydb/terraform-provider-dfcloud/internal/sdk"
99
"github.com/hashicorp/terraform-plugin-framework/resource"
1010
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
11+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
12+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
13+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1114
)
1215

1316
type NetworkResource struct {
@@ -41,6 +44,9 @@ func (r *NetworkResource) Schema(ctx context.Context, req resource.SchemaRequest
4144
"name": schema.StringAttribute{
4245
MarkdownDescription: "The name of the network.",
4346
Required: true,
47+
PlanModifiers: []planmodifier.String{
48+
stringplanmodifier.RequiresReplace(),
49+
},
4450
},
4551
"location": schema.SingleNestedAttribute{
4652
MarkdownDescription: "The location configuration for the network.",
@@ -55,10 +61,16 @@ func (r *NetworkResource) Schema(ctx context.Context, req resource.SchemaRequest
5561
Required: true,
5662
},
5763
},
64+
PlanModifiers: []planmodifier.Object{
65+
objectplanmodifier.RequiresReplace(),
66+
},
5867
},
5968
"cidr_block": schema.StringAttribute{
6069
MarkdownDescription: "The CIDR block for the network.",
6170
Required: true,
71+
PlanModifiers: []planmodifier.String{
72+
stringplanmodifier.RequiresReplace(),
73+
},
6274
},
6375
"vpc": schema.SingleNestedAttribute{
6476
MarkdownDescription: "The VPC information for the network.",

0 commit comments

Comments
 (0)