From 5358fcad9eb8dada121f4a856d58ad6acf8e58c2 Mon Sep 17 00:00:00 2001 From: Salima Hassouni Date: Mon, 3 Jun 2024 13:36:03 +0000 Subject: [PATCH] DBP-817-add ionoscloud_nic ressource --- modules/ionos-basic-vm-mariadb/main.tf | 13 ++++++++++++- modules/ionos-basic-vm-mariadb/output.tf | 4 ++++ modules/ionos-basic-vm-mariadb/variables.tf | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/ionos-basic-vm-mariadb/main.tf b/modules/ionos-basic-vm-mariadb/main.tf index 9ab8bc6..3b19490 100644 --- a/modules/ionos-basic-vm-mariadb/main.tf +++ b/modules/ionos-basic-vm-mariadb/main.tf @@ -24,7 +24,7 @@ module "basic-vm" { server_name = var.server_name ports = var.ports create_lan = true - lan_id = ionoscloud_lan.private_lan.id + # Ensure the private LAN is created before the basic VM depends_on = [ionoscloud_lan.private_lan] @@ -33,6 +33,17 @@ module "basic-vm" { initial_uid = "2215" initial_public_key = "../../../provision/sshkeys/technicaluser.pub" } + + +resource "ionoscloud_nic" "cluster_nic" { + count = var.cluster_lan_id == "" ? 0 : 1 + datacenter_id = var.datacenter_id + server_id = module.basic-vm.basic_vm_server_id + dhcp = true + lan = var.cluster_lan_id + ips = [var.cluster_lan_ip] + firewall_active = true +} # creates a new MariaDB cluster and connects it to the private LAN using the CIDR range obtained from the ionos-basic-vm module. resource "ionoscloud_mariadb_cluster" "mariadb_cluster" { mariadb_version = var.mariadb_version diff --git a/modules/ionos-basic-vm-mariadb/output.tf b/modules/ionos-basic-vm-mariadb/output.tf index 7d210e8..f5d7c1a 100644 --- a/modules/ionos-basic-vm-mariadb/output.tf +++ b/modules/ionos-basic-vm-mariadb/output.tf @@ -2,3 +2,7 @@ output "dns_name" { description = "The DNS name pointing to your cluster." value = ionoscloud_mariadb_cluster.mariadb_cluster.dns_name } + +output "cluster_lan_id" { + value = var.cluster_lan_id +} diff --git a/modules/ionos-basic-vm-mariadb/variables.tf b/modules/ionos-basic-vm-mariadb/variables.tf index 2472a87..de169fd 100644 --- a/modules/ionos-basic-vm-mariadb/variables.tf +++ b/modules/ionos-basic-vm-mariadb/variables.tf @@ -127,4 +127,12 @@ variable "mariadb_username" { variable "mariadb_password" { description = "The password for the initial mariadb user" type = string +} +variable "cluster_lan_id" { + type = number + description = "ID of the cluster LAN" +} +variable "cluster_lan_ip" { + type = string + description = "IP of the NFS server on the cluster LAN" } \ No newline at end of file