diff --git a/stackit/internal/services/iaas/iaas_acc_test.go b/stackit/internal/services/iaas/iaas_acc_test.go index d9aaf7a1e..96ff91bad 100644 --- a/stackit/internal/services/iaas/iaas_acc_test.go +++ b/stackit/internal/services/iaas/iaas_acc_test.go @@ -593,6 +593,7 @@ var testConfigRoutingTableMaxUpdated = func() config.Variables { updatedConfig["name"] = config.StringVariable(fmt.Sprintf("acc-test-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum))) updatedConfig["description"] = config.StringVariable("This is the updated description of the routing table.") updatedConfig["label"] = config.StringVariable("routing-table-updated-label-01") + updatedConfig["system_routes"] = config.BoolVariable(true) updatedConfig["dynamic_routes"] = config.BoolVariable(true) return updatedConfig }() @@ -4693,6 +4694,11 @@ func TestAccRoutingTableMin(t *testing.T) { { ConfigVariables: testConfigRoutingTableMin, Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMinConfig), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionCreate), + }, + }, Check: resource.ComposeAggregateTestCheckFunc( // Network Area 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) { `, testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMinConfig, ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionNoop), + }, + }, Check: resource.ComposeAggregateTestCheckFunc( // Routing table resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMin["organization_id"])), @@ -4831,6 +4842,11 @@ func TestAccRoutingTableMin(t *testing.T) { { ConfigVariables: testConfigRoutingTableMinUpdated, Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMinConfig), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionUpdate), + }, + }, Check: resource.ComposeAggregateTestCheckFunc( // Routing table resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMinUpdated["organization_id"])), @@ -4863,6 +4879,11 @@ func TestAccRoutingTableMax(t *testing.T) { { ConfigVariables: testConfigRoutingTableMax, Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMaxConfig), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionCreate), + }, + }, Check: resource.ComposeAggregateTestCheckFunc( // Network Area 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) { `, testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMaxConfig, ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionNoop), + }, + }, Check: resource.ComposeAggregateTestCheckFunc( // Routing table resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMax["organization_id"])), @@ -5002,6 +5028,11 @@ func TestAccRoutingTableMax(t *testing.T) { { ConfigVariables: testConfigRoutingTableMaxUpdated, Config: fmt.Sprintf("%s\n%s", testutil.IaaSProviderConfigWithExperiments(), resourceRoutingTableMaxConfig), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("stackit_routing_table.routing_table", plancheck.ResourceActionUpdate), + }, + }, Check: resource.ComposeAggregateTestCheckFunc( // Routing table resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "organization_id", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["organization_id"])), diff --git a/stackit/internal/services/iaas/routingtable/table/resource.go b/stackit/internal/services/iaas/routingtable/table/resource.go index d0e1328e9..f891a3839 100644 --- a/stackit/internal/services/iaas/routingtable/table/resource.go +++ b/stackit/internal/services/iaas/routingtable/table/resource.go @@ -8,7 +8,6 @@ import ( "time" "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" "github.com/stackitcloud/stackit-sdk-go/services/iaas" iaasUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/iaas/utils" @@ -202,9 +201,6 @@ func (r *routingTableResource) Schema(_ context.Context, _ resource.SchemaReques Optional: true, Computed: true, Default: booldefault.StaticBool(true), - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplace(), - }, }, "dynamic_routes": schema.BoolAttribute{ 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) Name: conversion.StringValueToPointer(model.Name), Labels: &labels, DynamicRoutes: conversion.BoolValueToPointer(model.DynamicRoutes), + SystemRoutes: conversion.BoolValueToPointer(model.SystemRoutes), }, nil } diff --git a/stackit/internal/services/iaas/routingtable/table/resource_test.go b/stackit/internal/services/iaas/routingtable/table/resource_test.go index 09997410e..2da1d999f 100644 --- a/stackit/internal/services/iaas/routingtable/table/resource_test.go +++ b/stackit/internal/services/iaas/routingtable/table/resource_test.go @@ -183,6 +183,7 @@ func TestToUpdatePayload(t *testing.T) { "key2": types.StringValue("value2"), }), DynamicRoutes: types.BoolValue(false), + SystemRoutes: types.BoolValue(false), }, &iaas.UpdateRoutingTableOfAreaPayload{ Description: utils.Ptr("Description"), @@ -192,6 +193,7 @@ func TestToUpdatePayload(t *testing.T) { "key2": "value2", }, DynamicRoutes: utils.Ptr(false), + SystemRoutes: utils.Ptr(false), }, true, },