Skip to content

Commit 353c02e

Browse files
authored
fix(iaas): remove recreate for routing-tables when system-routes property is updated (#1140)
1 parent d772e2e commit 353c02e

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

stackit/internal/services/iaas/iaas_acc_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ var testConfigRoutingTableMaxUpdated = func() config.Variables {
593593
updatedConfig["name"] = config.StringVariable(fmt.Sprintf("acc-test-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)))
594594
updatedConfig["description"] = config.StringVariable("This is the updated description of the routing table.")
595595
updatedConfig["label"] = config.StringVariable("routing-table-updated-label-01")
596+
updatedConfig["system_routes"] = config.BoolVariable(true)
596597
updatedConfig["dynamic_routes"] = config.BoolVariable(true)
597598
return updatedConfig
598599
}()
@@ -4693,6 +4694,11 @@ func TestAccRoutingTableMin(t *testing.T) {
46934694
{
46944695
ConfigVariables: testConfigRoutingTableMin,
46954696
Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMinConfig),
4697+
ConfigPlanChecks: resource.ConfigPlanChecks{
4698+
PreApply: []plancheck.PlanCheck{
4699+
plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionCreate),
4700+
},
4701+
},
46964702
Check: resource.ComposeAggregateTestCheckFunc(
46974703
// Network Area
46984704
resource.TestCheckResourceAttr("stackit_network_area_region.network_area_region", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMin["organization_id"])),
@@ -4750,6 +4756,11 @@ func TestAccRoutingTableMin(t *testing.T) {
47504756
`,
47514757
testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMinConfig,
47524758
),
4759+
ConfigPlanChecks: resource.ConfigPlanChecks{
4760+
PreApply: []plancheck.PlanCheck{
4761+
plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionNoop),
4762+
},
4763+
},
47534764
Check: resource.ComposeAggregateTestCheckFunc(
47544765
// Routing table
47554766
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMin["organization_id"])),
@@ -4831,6 +4842,11 @@ func TestAccRoutingTableMin(t *testing.T) {
48314842
{
48324843
ConfigVariables: testConfigRoutingTableMinUpdated,
48334844
Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMinConfig),
4845+
ConfigPlanChecks: resource.ConfigPlanChecks{
4846+
PreApply: []plancheck.PlanCheck{
4847+
plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionUpdate),
4848+
},
4849+
},
48344850
Check: resource.ComposeAggregateTestCheckFunc(
48354851
// Routing table
48364852
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMinUpdated["organization_id"])),
@@ -4863,6 +4879,11 @@ func TestAccRoutingTableMax(t *testing.T) {
48634879
{
48644880
ConfigVariables: testConfigRoutingTableMax,
48654881
Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMaxConfig),
4882+
ConfigPlanChecks: resource.ConfigPlanChecks{
4883+
PreApply: []plancheck.PlanCheck{
4884+
plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionCreate),
4885+
},
4886+
},
48664887
Check: resource.ComposeAggregateTestCheckFunc(
48674888
// Network Area
48684889
resource.TestCheckResourceAttr("stackit_network_area_region.network_area_region", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMax["organization_id"])),
@@ -4919,6 +4940,11 @@ func TestAccRoutingTableMax(t *testing.T) {
49194940
`,
49204941
testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMaxConfig,
49214942
),
4943+
ConfigPlanChecks: resource.ConfigPlanChecks{
4944+
PreApply: []plancheck.PlanCheck{
4945+
plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionNoop),
4946+
},
4947+
},
49224948
Check: resource.ComposeAggregateTestCheckFunc(
49234949
// Routing table
49244950
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMax["organization_id"])),
@@ -5002,6 +5028,11 @@ func TestAccRoutingTableMax(t *testing.T) {
50025028
{
50035029
ConfigVariables: testConfigRoutingTableMaxUpdated,
50045030
Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMaxConfig),
5031+
ConfigPlanChecks: resource.ConfigPlanChecks{
5032+
PreApply: []plancheck.PlanCheck{
5033+
plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionUpdate),
5034+
},
5035+
},
50055036
Check: resource.ComposeAggregateTestCheckFunc(
50065037
// Routing table
50075038
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["organization_id"])),

stackit/internal/services/iaas/routingtable/table/resource.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"time"
99

1010
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
11-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
1211
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1312

1413
iaasUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/utils"
@@ -202,9 +201,6 @@ func (r *routingTableResource) Schema(_ context.Context, _ resource.SchemaReques
202201
Optional: true,
203202
Computed: true,
204203
Default: booldefault.StaticBool(true),
205-
PlanModifiers: []planmodifier.Bool{
206-
boolplanmodifier.RequiresReplace(),
207-
},
208204
},
209205
"dynamic_routes": schema.BoolAttribute{
210206
Description: "This controls whether dynamic routes are propagated to this routing table",
@@ -531,5 +527,6 @@ func toUpdatePayload(ctx context.Context, model *Model, currentLabels types.Map)
531527
Name: conversion.StringValueToPointer(model.Name),
532528
Labels: &labels,
533529
DynamicRoutes: conversion.BoolValueToPointer(model.DynamicRoutes),
530+
SystemRoutes: conversion.BoolValueToPointer(model.SystemRoutes),
534531
}, nil
535532
}

stackit/internal/services/iaas/routingtable/table/resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func TestToUpdatePayload(t *testing.T) {
183183
"key2": types.StringValue("value2"),
184184
}),
185185
DynamicRoutes: types.BoolValue(false),
186+
SystemRoutes: types.BoolValue(false),
186187
},
187188
&iaas.UpdateRoutingTableOfAreaPayload{
188189
Description: utils.Ptr("Description"),
@@ -192,6 +193,7 @@ func TestToUpdatePayload(t *testing.T) {
192193
"key2": "value2",
193194
},
194195
DynamicRoutes: utils.Ptr(false),
196+
SystemRoutes: utils.Ptr(false),
195197
},
196198
true,
197199
},

0 commit comments

Comments
 (0)