From 2f005581e686dbfa88dff9c88c3be6a3a3d00cb3 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sat, 9 Oct 2021 23:15:46 +0200
Subject: [PATCH] terrafrom: Make subnets optional for instances

---
 terraform/modules/hcloud_instance/network.tf   | 2 +-
 terraform/modules/hcloud_instance/variables.tf | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/terraform/modules/hcloud_instance/network.tf b/terraform/modules/hcloud_instance/network.tf
index b21ddea3d..8d4e0a53e 100644
--- a/terraform/modules/hcloud_instance/network.tf
+++ b/terraform/modules/hcloud_instance/network.tf
@@ -1,5 +1,5 @@
 resource "hcloud_server_network" "server_network" {
   server_id = element(hcloud_server.server.*.id, count.index)
   subnet_id = var.subnet
-  count = length(hcloud_server.server.*.id)
+  count = var.subnet != null ? length(hcloud_server.server.*.id) : 0
 }
diff --git a/terraform/modules/hcloud_instance/variables.tf b/terraform/modules/hcloud_instance/variables.tf
index 325bf7333..9e6cf7130 100644
--- a/terraform/modules/hcloud_instance/variables.tf
+++ b/terraform/modules/hcloud_instance/variables.tf
@@ -92,4 +92,5 @@ variable "volume_size" {
 variable "subnet" {
   type        = string
   description = "Id of the additional internal network"
+  default     = null
 }
-- 
GitLab