fix dynamic private ip

This commit is contained in:
jodhi 2022-02-24 23:57:36 +07:00
parent 519cae04d3
commit b5039e2bc1
4 changed files with 6 additions and 14 deletions

View File

@ -35,7 +35,6 @@ locals {
for nodepool_name, nodepool_obj in var.agent_nodepools : { for nodepool_name, nodepool_obj in var.agent_nodepools : {
for index in range(lookup(nodepool_obj, "count", var.agents_num)) : for index in range(lookup(nodepool_obj, "count", var.agents_num)) :
format("%s-%s", nodepool_name, index) => { format("%s-%s", nodepool_name, index) => {
index : index, # just for the compatibility with previous structure
server_type : nodepool_obj.server_type server_type : nodepool_obj.server_type
} }
} }

View File

@ -12,11 +12,6 @@ resource "hcloud_server" "server" {
labels = var.labels labels = var.labels
network {
network_id = var.network_id
ip = try(var.ip, null)
}
connection { connection {
user = "root" user = "root"
private_key = local.ssh_private_key private_key = local.ssh_private_key
@ -68,3 +63,8 @@ resource "hcloud_server" "server" {
] ]
} }
} }
resource "hcloud_server_network" "server" {
server_id = hcloud_server.server.id
network_id = var.network_id
}

View File

@ -3,7 +3,7 @@ output "ipv4_address" {
} }
output "private_ipv4_address" { output "private_ipv4_address" {
value = var.ip value = hcloud_server_network.server.ip
} }
output "name" { output "name" {

View File

@ -59,13 +59,6 @@ variable "network_id" {
type = number type = number
} }
variable "ip" {
default = null
description = "The IP"
type = string
nullable = true
}
variable "server_type" { variable "server_type" {
description = "The server type" description = "The server type"
type = string type = string