resource "hcloud_network" "main" {
  name     = "${local.name_prefix}-net"
  ip_range = local.network_cidr

  labels = {
    environment = local.environment
  }
}

resource "hcloud_network_subnet" "app" {
  network_id   = hcloud_network.main.id
  type         = "cloud"
  network_zone = local.network_zone
  ip_range     = local.app_subnet_cidr
}

resource "hcloud_network_subnet" "db" {
  network_id   = hcloud_network.main.id
  type         = "cloud"
  network_zone = local.network_zone
  ip_range     = local.db_subnet_cidr
}
