Skip to content

Commit e64f6f3

Browse files
committed
refactor: remove unused network area routes and update routing configurations
1 parent f44e677 commit e64f6f3

5 files changed

Lines changed: 46 additions & 53 deletions

File tree

modules/connectivity-global/1-network-area.tf

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ resource "stackit_network_area" "this" {
1414

1515
organization_id = var.organization_id
1616
name = each.key
17-
labels = length(local.project_labels) > 0 ? local.project_labels : null
17+
labels = merge(local.project_labels, { "preview/routingtables" = "true" })
1818
}
1919

2020
resource "stackit_network_area_region" "this" {
@@ -31,18 +31,4 @@ resource "stackit_network_area_region" "this" {
3131
default_prefix_length = each.value.default_prefix_length
3232
default_nameservers = each.value.default_nameservers
3333
}
34-
}
35-
36-
############################
37-
## NETWORK AREA - ROUTING ##
38-
############################
39-
40-
resource "stackit_network_area_route" "this" {
41-
for_each = { for r in var.network_area_routes : r.name => r }
42-
43-
organization_id = var.organization_id
44-
network_area_id = stackit_network_area.this[each.value.network_area_name].network_area_id
45-
46-
destination = each.value.destination
47-
next_hop = each.value.next_hop
4834
}

modules/connectivity-global/variables.tf

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,11 @@ variable "network_areas" {
1818
max_prefix_length = optional(number, 28)
1919
min_prefix_length = optional(number, 24)
2020
default_prefix_length = optional(number, 28)
21-
default_nameservers = optional(list(string), null)
21+
default_nameservers = optional(list(string), ["1.0.0.1", "1.1.1.1"])
2222
}))
2323
description = "List of network areas to create, each with its own name, ranges, and configuration."
2424
}
2525

26-
variable "network_area_routes" {
27-
type = list(object({
28-
name = string
29-
network_area_name = string
30-
destination = object({
31-
type = string
32-
value = string
33-
})
34-
next_hop = object({
35-
type = string
36-
value = optional(string)
37-
})
38-
}))
39-
description = "List of static routes to create within network areas. Each route references a network area by name."
40-
default = []
41-
}
42-
4326
variable "organization_id" {
4427
type = string
4528
description = "Container ID of the root folder or organization under which the company folder will be created."

modules/connectivity-regional/2-network.tf

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@
22
## NETWORKS ##
33
##############
44

5-
# will get auto assigned a free range from the network area
6-
resource "stackit_network" "hub" {
5+
resource "stackit_network" "lan" {
76
project_id = stackit_resourcemanager_project.this.project_id
8-
name = "hub_network"
7+
name = "lan_network"
98
routed = true
109
}
1110

11+
resource "stackit_network" "wan" {
12+
project_id = stackit_resourcemanager_project.this.project_id
13+
name = "wan_network"
14+
routing_table_id = stackit_routing_table.wan.routing_table_id
15+
routed = true # needs to be true, since floating will be attached to router; also means connected to network area --> will get routes from there as well
16+
}
17+
1218
################
1319
## INTERFACES ##
1420
################
1521

1622
resource "stackit_network_interface" "wan" {
1723
name = "vtnet0_wan"
1824
project_id = stackit_resourcemanager_project.this.project_id
19-
network_id = stackit_network.hub.network_id
25+
network_id = stackit_network.wan.network_id
2026
security = false
2127
}
2228

2329
resource "stackit_network_interface" "lan" {
2430
name = "vtnet1_lan"
2531
project_id = stackit_resourcemanager_project.this.project_id
26-
network_id = stackit_network.hub.network_id
32+
network_id = stackit_network.lan.network_id
2733
security = false
2834
}
2935

modules/connectivity-regional/3-firewall.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource "stackit_server" "pfsense_Server" {
5656
}
5757
availability_zone = var.firewall_zone
5858
machine_type = var.firewall_flavor
59-
59+
6060
network_interfaces = [
6161
stackit_network_interface.wan.network_interface_id, # vtnet0 = WAN
6262
stackit_network_interface.lan.network_interface_id # vtnet1 = LAN
Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
1-
#########################
2-
## NETWORK AREA ROUTES ##
3-
#########################
1+
####################
2+
## FIREWALL ROUTE ##
3+
####################
44

5-
resource "stackit_network_area_route" "rfc1918_10" {
5+
resource "stackit_routing_table" "wan" {
66
organization_id = var.organization_id
77
network_area_id = var.network_area_id
8-
destination = { type = "cidrv4", value = "10.0.0.0/8" }
9-
next_hop = { type = "ipv4", value = stackit_network_interface.lan.ipv4 }
8+
name = "wan"
109
}
1110

12-
resource "stackit_network_area_route" "rfc1918_172" {
13-
organization_id = var.organization_id
14-
network_area_id = var.network_area_id
15-
destination = { type = "cidrv4", value = "172.16.0.0/12" }
16-
next_hop = { type = "ipv4", value = stackit_network_interface.lan.ipv4 }
11+
resource "stackit_routing_table_route" "wan" {
12+
organization_id = var.organization_id
13+
network_area_id = var.network_area_id
14+
routing_table_id = stackit_routing_table.wan.routing_table_id
15+
16+
destination = {
17+
type = "cidrv4"
18+
value = "0.0.0.0/0"
19+
}
20+
21+
next_hop = {
22+
type = "internet"
23+
}
1724
}
1825

19-
resource "stackit_network_area_route" "rfc1918_192" {
26+
#########################
27+
## NETWORK AREA ROUTES ##
28+
#########################
29+
30+
resource "stackit_network_area_route" "default" {
2031
organization_id = var.organization_id
2132
network_area_id = var.network_area_id
22-
destination = { type = "cidrv4", value = "192.168.0.0/16" }
23-
next_hop = { type = "ipv4", value = stackit_network_interface.lan.ipv4 }
33+
34+
destination = {
35+
type = "cidrv4"
36+
value = "0.0.0.0/0"
37+
}
38+
next_hop = {
39+
type = "ipv4"
40+
value = stackit_network_interface.lan.ipv4
41+
}
2442
}

0 commit comments

Comments
 (0)