Skip to content

Commit

Permalink
DBP-817-add ionoscloud_nic ressource
Browse files Browse the repository at this point in the history
  • Loading branch information
sahassou committed Jun 3, 2024
1 parent 82b5ee0 commit 5358fca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/ionos-basic-vm-mariadb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modules/ionos-basic-vm-mariadb/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 8 additions & 0 deletions modules/ionos-basic-vm-mariadb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 5358fca

Please sign in to comment.