Migrate to Hetzner cloud

This commit is contained in:
Paul-Henri Froidmont 2019-08-22 05:11:27 +02:00
parent d3c99dad0b
commit c311cd4f7e
37 changed files with 416 additions and 299 deletions

View file

@ -1,27 +1,41 @@
data "scaleway_image" "ubuntu" {
architecture = var.architecture
name = var.image
resource "hcloud_server" "node" {
count = var.node_server_count
name = "node${count.index + 1}"
image = "ubuntu-18.04"
server_type = var.node_server_type
ssh_keys = [hcloud_ssh_key.desktop.id]
keep_disk = true
labels = {
environment = local.environment
type = "node"
}
}
resource "scaleway_server" "node" {
count = var.node_instance_count
name = "node${count.index + 1}"
image = data.scaleway_image.ubuntu.id
type = var.node_instance_type
state = "running"
dynamic_ip_required = true
tags = ["${local.environment}-node"]
resource "hcloud_server_network" "node_network" {
count = var.node_server_count
server_id = "${hcloud_server.node[count.index].id}"
network_id = "${hcloud_network.private_network.id}"
ip = "192.168.2.${count.index + 1}"
}
resource "scaleway_server" "master" {
count = var.master_instance_count
name = "master${count.index + 1}"
image = data.scaleway_image.ubuntu.id
type = var.master_instance_type
state = "running"
dynamic_ip_required = true
tags = [
"${local.environment}-master",
"${local.environment}-etcd",
]
resource "hcloud_server" "master" {
count = var.master_server_count
name = "master${count.index + 1}"
image = "ubuntu-18.04"
server_type = var.master_server_type
ssh_keys = [hcloud_ssh_key.desktop.id]
keep_disk = true
labels = {
environment = local.environment
type = "master"
}
}
resource "hcloud_server_network" "master_network" {
count = var.master_server_count
server_id = "${hcloud_server.master[count.index].id}"
network_id = "${hcloud_network.private_network.id}"
ip = "192.168.1.${count.index + 1}"
}