Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data-sources/routing_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ data "stackit_routing_table" "example" {
- `created_at` (String) Date-time when the routing table was created
- `default` (Boolean) When true this is the default routing table for this network area. It can't be deleted and is used if the user does not specify it otherwise.
- `description` (String) Description of the routing table.
- `dynamic_routes` (Boolean) This controls whether dynamic routes are propagated to this routing table
- `id` (String) Terraform's internal datasource ID. It is structured as "`organization_id`,`region`,`network_area_id`,`routing_table_id`".
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
- `name` (String) The name of the routing table.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/routing_tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Read-Only:
- `created_at` (String) Date-time when the routing table was created
- `default` (Boolean) When true this is the default routing table for this network area. It can't be deleted and is used if the user does not specify it otherwise.
- `description` (String) Description of the routing table.
- `dynamic_routes` (Boolean) This controls whether dynamic routes are propagated to this routing table
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
- `name` (String) The name of the routing table.
- `routing_table_id` (String) The routing tables ID.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/routing_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
### Optional

- `description` (String) Description of the routing table.
- `dynamic_routes` (Boolean) This controls whether dynamic routes are propagated to this routing table
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
- `region` (String) The resource region. If not defined, the provider region is used.
- `system_routes` (Boolean) This controls whether the routes for project-to-project communication are created automatically or not.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.3
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.1
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha
github.com/stackitcloud/stackit-sdk-go/services/kms v1.2.0
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.2
github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ github.com/stackitcloud/stackit-sdk-go/services/git v0.10.1 h1:3JKXfI5hdcXcRVBjU
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.1/go.mod h1:3nTaj8IGjNNGYUD2CpuXkXwc5c4giTUmoPggFhjVFxo=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0 h1:U/x0tc487X9msMS5yZYjrBAAKrCx87Trmt0kh8JiARA=
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0/go.mod h1:6+5+RCDfU7eQN3+/SGdOtx7Bq9dEa2FrHz/jflgY1M4=
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha h1:m1jq6a8dbUe+suFuUNdHmM/cSehpGLUtDbK1CqLqydg=
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha/go.mod h1:Nu1b5Phsv8plgZ51+fkxPVsU91ZJ5Ayz+cthilxdmQ8=
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha h1:ugpMOMUZGB0yXsWcfe97F7GCdjlexbjFuGD8ZeyMSts=
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha/go.mod h1:v5VGvTxLcCdJJmblbhqYalt/MFHcElDfYoy15CMhaWs=
github.com/stackitcloud/stackit-sdk-go/services/kms v1.2.0 h1:Ar2n9GKmrTN80G/Ta1R+fL5aX5nEoxL6ODVJl3emzho=
github.com/stackitcloud/stackit-sdk-go/services/kms v1.2.0/go.mod h1:sHMFoYvVrkRZcH13DkLvp48nW+ssRVVVuwqJHDGpa5M=
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.2 h1:DwwRMzvnKWTbfmLvq2xe+mYhv5fA1AwWdQGznI05sGc=
Expand Down
3 changes: 3 additions & 0 deletions stackit/internal/services/iaas/iaas_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ func TestAccNetworkMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
),
Expand Down Expand Up @@ -803,6 +804,7 @@ func TestAccNetworkMax(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "region", testutil.Region),
resource.TestCheckNoResourceAttr("data.stackit_routing_table.routing_table", "description"),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "system_routes", "true"),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "dynamic_routes", "true"),
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "updated_at"),
),
Expand Down Expand Up @@ -952,6 +954,7 @@ func TestAccNetworkMax(t *testing.T) {
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
),
Expand Down
10 changes: 10 additions & 0 deletions stackit/internal/services/iaasalpha/iaasalpha_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var testConfigRoutingTableMax = config.Variables{
"description": config.StringVariable("This is the description of the routing table."),
"label": config.StringVariable("routing-table-label-01"),
"system_routes": config.BoolVariable(false),
"dynamic_routes": config.BoolVariable(false),
"region": config.StringVariable(testutil.Region),
}

Expand All @@ -73,6 +74,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["dynamic_routes"] = config.BoolVariable(true)
return updatedConfig
}()

Expand Down Expand Up @@ -133,6 +135,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
),
Expand Down Expand Up @@ -172,6 +175,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "region", testutil.Region),
resource.TestCheckNoResourceAttr("data.stackit_routing_table.routing_table", "description"),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "system_routes", "true"),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "dynamic_routes", "true"),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "default", "false"),
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "updated_at"),
Expand All @@ -197,6 +201,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.labels.%", "0"),
resource.TestCheckNoResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.description"),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.system_routes", "true"),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.dynamic_routes", "true"),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.default", "false"),
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.created_at"),
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.updated_at"),
Expand Down Expand Up @@ -242,6 +247,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
),
Expand Down Expand Up @@ -272,6 +278,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.ConvertConfigVariable(testConfigRoutingTableMax["region"])),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "description", testutil.ConvertConfigVariable(testConfigRoutingTableMax["description"])),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["system_routes"])),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["dynamic_routes"])),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
),
Expand Down Expand Up @@ -312,6 +319,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "region", testutil.ConvertConfigVariable(testConfigRoutingTableMax["region"])),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "description", testutil.ConvertConfigVariable(testConfigRoutingTableMax["description"])),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["system_routes"])),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["dynamic_routes"])),
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "default", "false"),
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "updated_at"),
Expand All @@ -338,6 +346,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.labels.acc-test", testutil.ConvertConfigVariable(testConfigRoutingTableMax["label"])),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.description", testutil.ConvertConfigVariable(testConfigRoutingTableMax["description"])),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["system_routes"])),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["dynamic_routes"])),
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.default", "false"),
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.created_at"),
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.updated_at"),
Expand Down Expand Up @@ -384,6 +393,7 @@ func TestAccRoutingTable(t *testing.T) {
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["region"])),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "description", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["description"])),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["system_routes"])),
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["dynamic_routes"])),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type RoutingTableReadModel struct {
UpdatedAt types.String `tfsdk:"updated_at"`
Default types.Bool `tfsdk:"default"`
SystemRoutes types.Bool `tfsdk:"system_routes"`
DynamicRoutes types.Bool `tfsdk:"dynamic_routes"`
}

func RoutingTableReadModelTypes() map[string]attr.Type {
Expand All @@ -38,6 +39,7 @@ func RoutingTableReadModelTypes() map[string]attr.Type {
"updated_at": types.StringType,
"default": types.BoolType,
"system_routes": types.BoolType,
"dynamic_routes": types.BoolType,
}
}

Expand Down Expand Up @@ -208,6 +210,10 @@ func RoutingTableResponseAttributes() map[string]schema.Attribute {
Description: "This controls whether the routes for project-to-project communication are created automatically or not.",
Computed: true,
},
"dynamic_routes": schema.BoolAttribute{
Description: "This controls whether dynamic routes are propagated to this routing table",
Computed: true,
},
"created_at": schema.StringAttribute{
Description: "Date-time when the routing table was created",
Computed: true,
Expand Down Expand Up @@ -257,6 +263,7 @@ func MapRoutingTableReadModel(ctx context.Context, routingTable *iaasalpha.Routi
model.Description = types.StringPointerValue(routingTable.Description)
model.Default = types.BoolPointerValue(routingTable.Default)
model.SystemRoutes = types.BoolPointerValue(routingTable.SystemRoutes)
model.DynamicRoutes = types.BoolPointerValue(routingTable.DynamicRoutes)
model.Labels = labels
model.CreatedAt = createdAtTF
model.UpdatedAt = updatedAtTF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Model struct {
Labels types.Map `tfsdk:"labels"`
Region types.String `tfsdk:"region"`
SystemRoutes types.Bool `tfsdk:"system_routes"`
DynamicRoutes types.Bool `tfsdk:"dynamic_routes"`
CreatedAt types.String `tfsdk:"created_at"`
UpdatedAt types.String `tfsdk:"updated_at"`
}
Expand Down Expand Up @@ -206,6 +207,12 @@ func (r *routingTableResource) Schema(_ context.Context, _ resource.SchemaReques
boolplanmodifier.RequiresReplace(),
},
},
"dynamic_routes": schema.BoolAttribute{
Description: "This controls whether dynamic routes are propagated to this routing table",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(true),
},
"created_at": schema.StringAttribute{
Description: "Date-time when the routing table was created",
Computed: true,
Expand Down Expand Up @@ -485,6 +492,7 @@ func mapFields(ctx context.Context, routingTable *iaasalpha.RoutingTable, model
model.Labels = labels
model.Region = types.StringValue(region)
model.SystemRoutes = types.BoolPointerValue(routingTable.SystemRoutes)
model.DynamicRoutes = types.BoolPointerValue(routingTable.DynamicRoutes)
model.CreatedAt = createdAtTF
model.UpdatedAt = updatedAtTF
return nil
Expand All @@ -501,10 +509,11 @@ func toCreatePayload(ctx context.Context, model *Model) (*iaasalpha.AddRoutingTa
}

return &iaasalpha.AddRoutingTableToAreaPayload{
Description: conversion.StringValueToPointer(model.Description),
Name: conversion.StringValueToPointer(model.Name),
Labels: &labels,
SystemRoutes: conversion.BoolValueToPointer(model.SystemRoutes),
Description: conversion.StringValueToPointer(model.Description),
Name: conversion.StringValueToPointer(model.Name),
Labels: &labels,
SystemRoutes: conversion.BoolValueToPointer(model.SystemRoutes),
DynamicRoutes: conversion.BoolValueToPointer(model.DynamicRoutes),
}, nil
}

Expand All @@ -519,8 +528,9 @@ func toUpdatePayload(ctx context.Context, model *Model, currentLabels types.Map)
}

return &iaasalpha.UpdateRoutingTableOfAreaPayload{
Description: conversion.StringValueToPointer(model.Description),
Name: conversion.StringValueToPointer(model.Name),
Labels: &labels,
Description: conversion.StringValueToPointer(model.Description),
Name: conversion.StringValueToPointer(model.Name),
Labels: &labels,
DynamicRoutes: conversion.BoolValueToPointer(model.DynamicRoutes),
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,17 @@ func TestToCreatePayload(t *testing.T) {
Labels: types.MapValueMust(types.StringType, map[string]attr.Value{
"key": types.StringValue("value"),
}),
SystemRoutes: types.BoolValue(true),
SystemRoutes: types.BoolValue(true),
DynamicRoutes: types.BoolValue(true),
},
expected: &iaasalpha.AddRoutingTableToAreaPayload{
Description: utils.Ptr("Description"),
Name: utils.Ptr("default_ok"),
Labels: &map[string]interface{}{
"key": "value",
},
SystemRoutes: utils.Ptr(true),
SystemRoutes: utils.Ptr(true),
DynamicRoutes: utils.Ptr(true),
},
isValid: true,
},
Expand Down Expand Up @@ -180,6 +182,7 @@ func TestToUpdatePayload(t *testing.T) {
"key1": types.StringValue("value1"),
"key2": types.StringValue("value2"),
}),
DynamicRoutes: types.BoolValue(false),
},
&iaasalpha.UpdateRoutingTableOfAreaPayload{
Description: utils.Ptr("Description"),
Expand All @@ -188,6 +191,7 @@ func TestToUpdatePayload(t *testing.T) {
"key1": "value1",
"key2": "value2",
},
DynamicRoutes: utils.Ptr(false),
},
true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func mapDataSourceRoutingTables(ctx context.Context, routingTables *iaasalpha.Ro
"updated_at": routingTableModel.UpdatedAt,
"default": routingTableModel.Default,
"system_routes": routingTableModel.SystemRoutes,
"dynamic_routes": routingTableModel.DynamicRoutes,
}

routingTableTF, diags := types.ObjectValue(shared.RoutingTableReadModelTypes(), routingTableMap)
Expand Down
Loading
Loading