Skip to content

Commit 122e0c8

Browse files
authored
feat(iaas): add dynamic_routes field to routing table (#1110)
1 parent 6c9752a commit 122e0c8

File tree

13 files changed

+80
-34
lines changed

13 files changed

+80
-34
lines changed

docs/data-sources/routing_table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ data "stackit_routing_table" "example" {
4141
- `created_at` (String) Date-time when the routing table was created
4242
- `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.
4343
- `description` (String) Description of the routing table.
44+
- `dynamic_routes` (Boolean) This controls whether dynamic routes are propagated to this routing table
4445
- `id` (String) Terraform's internal datasource ID. It is structured as "`organization_id`,`region`,`network_area_id`,`routing_table_id`".
4546
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
4647
- `name` (String) The name of the routing table.

docs/data-sources/routing_tables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Read-Only:
4747
- `created_at` (String) Date-time when the routing table was created
4848
- `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.
4949
- `description` (String) Description of the routing table.
50+
- `dynamic_routes` (Boolean) This controls whether dynamic routes are propagated to this routing table
5051
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
5152
- `name` (String) The name of the routing table.
5253
- `routing_table_id` (String) The routing tables ID.

docs/resources/routing_table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
### Optional
4545

4646
- `description` (String) Description of the routing table.
47+
- `dynamic_routes` (Boolean) This controls whether dynamic routes are propagated to this routing table
4748
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container
4849
- `region` (String) The resource region. If not defined, the provider region is used.
4950
- `system_routes` (Boolean) This controls whether the routes for project-to-project communication are created automatically or not.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.3
1717
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.1
1818
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0
19-
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha
19+
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha
2020
github.com/stackitcloud/stackit-sdk-go/services/kms v1.2.0
2121
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.2
2222
github.com/stackitcloud/stackit-sdk-go/services/logme v0.25.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ github.com/stackitcloud/stackit-sdk-go/services/git v0.10.1 h1:3JKXfI5hdcXcRVBjU
161161
github.com/stackitcloud/stackit-sdk-go/services/git v0.10.1/go.mod h1:3nTaj8IGjNNGYUD2CpuXkXwc5c4giTUmoPggFhjVFxo=
162162
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0 h1:U/x0tc487X9msMS5yZYjrBAAKrCx87Trmt0kh8JiARA=
163163
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.3.0/go.mod h1:6+5+RCDfU7eQN3+/SGdOtx7Bq9dEa2FrHz/jflgY1M4=
164-
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha h1:m1jq6a8dbUe+suFuUNdHmM/cSehpGLUtDbK1CqLqydg=
165-
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.21-alpha/go.mod h1:Nu1b5Phsv8plgZ51+fkxPVsU91ZJ5Ayz+cthilxdmQ8=
164+
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha h1:ugpMOMUZGB0yXsWcfe97F7GCdjlexbjFuGD8ZeyMSts=
165+
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha/go.mod h1:v5VGvTxLcCdJJmblbhqYalt/MFHcElDfYoy15CMhaWs=
166166
github.com/stackitcloud/stackit-sdk-go/services/kms v1.2.0 h1:Ar2n9GKmrTN80G/Ta1R+fL5aX5nEoxL6ODVJl3emzho=
167167
github.com/stackitcloud/stackit-sdk-go/services/kms v1.2.0/go.mod h1:sHMFoYvVrkRZcH13DkLvp48nW+ssRVVVuwqJHDGpa5M=
168168
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.6.2 h1:DwwRMzvnKWTbfmLvq2xe+mYhv5fA1AwWdQGznI05sGc=

stackit/internal/services/iaas/iaas_acc_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ func TestAccNetworkMax(t *testing.T) {
719719
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
720720
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
721721
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
722+
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
722723
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
723724
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
724725
),
@@ -803,6 +804,7 @@ func TestAccNetworkMax(t *testing.T) {
803804
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "region", testutil.Region),
804805
resource.TestCheckNoResourceAttr("data.stackit_routing_table.routing_table", "description"),
805806
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "system_routes", "true"),
807+
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "dynamic_routes", "true"),
806808
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "created_at"),
807809
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "updated_at"),
808810
),
@@ -952,6 +954,7 @@ func TestAccNetworkMax(t *testing.T) {
952954
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
953955
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
954956
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
957+
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
955958
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
956959
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
957960
),

stackit/internal/services/iaasalpha/iaasalpha_acc_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var testConfigRoutingTableMax = config.Variables{
6262
"description": config.StringVariable("This is the description of the routing table."),
6363
"label": config.StringVariable("routing-table-label-01"),
6464
"system_routes": config.BoolVariable(false),
65+
"dynamic_routes": config.BoolVariable(false),
6566
"region": config.StringVariable(testutil.Region),
6667
}
6768

@@ -73,6 +74,7 @@ var testConfigRoutingTableMaxUpdated = func() config.Variables {
7374
updatedConfig["name"] = config.StringVariable(fmt.Sprintf("acc-test-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)))
7475
updatedConfig["description"] = config.StringVariable("This is the updated description of the routing table.")
7576
updatedConfig["label"] = config.StringVariable("routing-table-updated-label-01")
77+
updatedConfig["dynamic_routes"] = config.BoolVariable(true)
7678
return updatedConfig
7779
}()
7880

@@ -133,6 +135,7 @@ func TestAccRoutingTable(t *testing.T) {
133135
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
134136
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
135137
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
138+
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
136139
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
137140
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
138141
),
@@ -172,6 +175,7 @@ func TestAccRoutingTable(t *testing.T) {
172175
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "region", testutil.Region),
173176
resource.TestCheckNoResourceAttr("data.stackit_routing_table.routing_table", "description"),
174177
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "system_routes", "true"),
178+
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "dynamic_routes", "true"),
175179
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "default", "false"),
176180
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "created_at"),
177181
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "updated_at"),
@@ -197,6 +201,7 @@ func TestAccRoutingTable(t *testing.T) {
197201
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.labels.%", "0"),
198202
resource.TestCheckNoResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.description"),
199203
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.system_routes", "true"),
204+
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.dynamic_routes", "true"),
200205
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.default", "false"),
201206
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.created_at"),
202207
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.updated_at"),
@@ -242,6 +247,7 @@ func TestAccRoutingTable(t *testing.T) {
242247
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.Region),
243248
resource.TestCheckNoResourceAttr("stackit_routing_table.routing_table", "description"),
244249
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", "true"),
250+
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", "true"),
245251
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
246252
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
247253
),
@@ -272,6 +278,7 @@ func TestAccRoutingTable(t *testing.T) {
272278
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.ConvertConfigVariable(testConfigRoutingTableMax["region"])),
273279
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "description", testutil.ConvertConfigVariable(testConfigRoutingTableMax["description"])),
274280
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["system_routes"])),
281+
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["dynamic_routes"])),
275282
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
276283
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
277284
),
@@ -312,6 +319,7 @@ func TestAccRoutingTable(t *testing.T) {
312319
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "region", testutil.ConvertConfigVariable(testConfigRoutingTableMax["region"])),
313320
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "description", testutil.ConvertConfigVariable(testConfigRoutingTableMax["description"])),
314321
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["system_routes"])),
322+
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["dynamic_routes"])),
315323
resource.TestCheckResourceAttr("data.stackit_routing_table.routing_table", "default", "false"),
316324
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "created_at"),
317325
resource.TestCheckResourceAttrSet("data.stackit_routing_table.routing_table", "updated_at"),
@@ -338,6 +346,7 @@ func TestAccRoutingTable(t *testing.T) {
338346
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.labels.acc-test", testutil.ConvertConfigVariable(testConfigRoutingTableMax["label"])),
339347
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.description", testutil.ConvertConfigVariable(testConfigRoutingTableMax["description"])),
340348
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["system_routes"])),
349+
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMax["dynamic_routes"])),
341350
resource.TestCheckResourceAttr("data.stackit_routing_tables.routing_tables", "items.1.default", "false"),
342351
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.created_at"),
343352
resource.TestCheckResourceAttrSet("data.stackit_routing_tables.routing_tables", "items.1.updated_at"),
@@ -384,6 +393,7 @@ func TestAccRoutingTable(t *testing.T) {
384393
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "region", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["region"])),
385394
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "description", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["description"])),
386395
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "system_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["system_routes"])),
396+
resource.TestCheckResourceAttr("stackit_routing_table.routing_table", "dynamic_routes", testutil.ConvertConfigVariable(testConfigRoutingTableMaxUpdated["dynamic_routes"])),
387397
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "created_at"),
388398
resource.TestCheckResourceAttrSet("stackit_routing_table.routing_table", "updated_at"),
389399
),

stackit/internal/services/iaasalpha/routingtable/shared/shared.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type RoutingTableReadModel struct {
2626
UpdatedAt types.String `tfsdk:"updated_at"`
2727
Default types.Bool `tfsdk:"default"`
2828
SystemRoutes types.Bool `tfsdk:"system_routes"`
29+
DynamicRoutes types.Bool `tfsdk:"dynamic_routes"`
2930
}
3031

3132
func RoutingTableReadModelTypes() map[string]attr.Type {
@@ -38,6 +39,7 @@ func RoutingTableReadModelTypes() map[string]attr.Type {
3839
"updated_at": types.StringType,
3940
"default": types.BoolType,
4041
"system_routes": types.BoolType,
42+
"dynamic_routes": types.BoolType,
4143
}
4244
}
4345

@@ -208,6 +210,10 @@ func RoutingTableResponseAttributes() map[string]schema.Attribute {
208210
Description: "This controls whether the routes for project-to-project communication are created automatically or not.",
209211
Computed: true,
210212
},
213+
"dynamic_routes": schema.BoolAttribute{
214+
Description: "This controls whether dynamic routes are propagated to this routing table",
215+
Computed: true,
216+
},
211217
"created_at": schema.StringAttribute{
212218
Description: "Date-time when the routing table was created",
213219
Computed: true,
@@ -257,6 +263,7 @@ func MapRoutingTableReadModel(ctx context.Context, routingTable *iaasalpha.Routi
257263
model.Description = types.StringPointerValue(routingTable.Description)
258264
model.Default = types.BoolPointerValue(routingTable.Default)
259265
model.SystemRoutes = types.BoolPointerValue(routingTable.SystemRoutes)
266+
model.DynamicRoutes = types.BoolPointerValue(routingTable.DynamicRoutes)
260267
model.Labels = labels
261268
model.CreatedAt = createdAtTF
262269
model.UpdatedAt = updatedAtTF

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Model struct {
4848
Labels types.Map `tfsdk:"labels"`
4949
Region types.String `tfsdk:"region"`
5050
SystemRoutes types.Bool `tfsdk:"system_routes"`
51+
DynamicRoutes types.Bool `tfsdk:"dynamic_routes"`
5152
CreatedAt types.String `tfsdk:"created_at"`
5253
UpdatedAt types.String `tfsdk:"updated_at"`
5354
}
@@ -206,6 +207,12 @@ func (r *routingTableResource) Schema(_ context.Context, _ resource.SchemaReques
206207
boolplanmodifier.RequiresReplace(),
207208
},
208209
},
210+
"dynamic_routes": schema.BoolAttribute{
211+
Description: "This controls whether dynamic routes are propagated to this routing table",
212+
Optional: true,
213+
Computed: true,
214+
Default: booldefault.StaticBool(true),
215+
},
209216
"created_at": schema.StringAttribute{
210217
Description: "Date-time when the routing table was created",
211218
Computed: true,
@@ -485,6 +492,7 @@ func mapFields(ctx context.Context, routingTable *iaasalpha.RoutingTable, model
485492
model.Labels = labels
486493
model.Region = types.StringValue(region)
487494
model.SystemRoutes = types.BoolPointerValue(routingTable.SystemRoutes)
495+
model.DynamicRoutes = types.BoolPointerValue(routingTable.DynamicRoutes)
488496
model.CreatedAt = createdAtTF
489497
model.UpdatedAt = updatedAtTF
490498
return nil
@@ -501,10 +509,11 @@ func toCreatePayload(ctx context.Context, model *Model) (*iaasalpha.AddRoutingTa
501509
}
502510

503511
return &iaasalpha.AddRoutingTableToAreaPayload{
504-
Description: conversion.StringValueToPointer(model.Description),
505-
Name: conversion.StringValueToPointer(model.Name),
506-
Labels: &labels,
507-
SystemRoutes: conversion.BoolValueToPointer(model.SystemRoutes),
512+
Description: conversion.StringValueToPointer(model.Description),
513+
Name: conversion.StringValueToPointer(model.Name),
514+
Labels: &labels,
515+
SystemRoutes: conversion.BoolValueToPointer(model.SystemRoutes),
516+
DynamicRoutes: conversion.BoolValueToPointer(model.DynamicRoutes),
508517
}, nil
509518
}
510519

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

521530
return &iaasalpha.UpdateRoutingTableOfAreaPayload{
522-
Description: conversion.StringValueToPointer(model.Description),
523-
Name: conversion.StringValueToPointer(model.Name),
524-
Labels: &labels,
531+
Description: conversion.StringValueToPointer(model.Description),
532+
Name: conversion.StringValueToPointer(model.Name),
533+
Labels: &labels,
534+
DynamicRoutes: conversion.BoolValueToPointer(model.DynamicRoutes),
525535
}, nil
526536
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,17 @@ func TestToCreatePayload(t *testing.T) {
132132
Labels: types.MapValueMust(types.StringType, map[string]attr.Value{
133133
"key": types.StringValue("value"),
134134
}),
135-
SystemRoutes: types.BoolValue(true),
135+
SystemRoutes: types.BoolValue(true),
136+
DynamicRoutes: types.BoolValue(true),
136137
},
137138
expected: &iaasalpha.AddRoutingTableToAreaPayload{
138139
Description: utils.Ptr("Description"),
139140
Name: utils.Ptr("default_ok"),
140141
Labels: &map[string]interface{}{
141142
"key": "value",
142143
},
143-
SystemRoutes: utils.Ptr(true),
144+
SystemRoutes: utils.Ptr(true),
145+
DynamicRoutes: utils.Ptr(true),
144146
},
145147
isValid: true,
146148
},
@@ -180,6 +182,7 @@ func TestToUpdatePayload(t *testing.T) {
180182
"key1": types.StringValue("value1"),
181183
"key2": types.StringValue("value2"),
182184
}),
185+
DynamicRoutes: types.BoolValue(false),
183186
},
184187
&iaasalpha.UpdateRoutingTableOfAreaPayload{
185188
Description: utils.Ptr("Description"),
@@ -188,6 +191,7 @@ func TestToUpdatePayload(t *testing.T) {
188191
"key1": "value1",
189192
"key2": "value2",
190193
},
194+
DynamicRoutes: utils.Ptr(false),
191195
},
192196
true,
193197
},

0 commit comments

Comments
 (0)