self-hosting/instances.tf

87 lines
1.6 KiB
Terraform
Raw Normal View History

data "hcloud_image" "nixos_stable" {
with_selector = "nixos=21.05"
}
resource "hcloud_network" "private_network" {
2021-11-29 02:04:29 +01:00
name = "private"
ip_range = "10.0.0.0/16"
}
resource "hcloud_network_subnet" "db_network_subnet" {
2021-11-29 02:04:29 +01:00
type = "cloud"
network_id = hcloud_network.private_network.id
network_zone = "eu-central"
2021-11-29 02:04:29 +01:00
ip_range = "10.0.1.0/24"
}
2021-07-17 00:24:30 +02:00
resource "hcloud_network_subnet" "banditlair_vswitch_network_subnet" {
2021-11-29 02:04:29 +01:00
type = "vswitch"
network_id = hcloud_network.private_network.id
2021-07-17 00:24:30 +02:00
network_zone = "eu-central"
2021-11-29 02:04:29 +01:00
ip_range = "10.0.2.0/24"
2022-04-01 01:22:29 +02:00
vswitch_id = 29224
2021-07-17 00:24:30 +02:00
}
resource "hcloud_server" "db1" {
2021-11-29 02:04:29 +01:00
name = "db1"
image = data.hcloud_image.nixos_stable.id
server_type = "cpx11"
ssh_keys = [
2022-11-07 04:53:09 +01:00
hcloud_ssh_key.froidmpa-desktop.id
]
keep_disk = true
2023-02-07 23:11:14 +01:00
location = "fsn1"
network {
network_id = hcloud_network.private_network.id
2021-11-29 02:04:29 +01:00
ip = "10.0.1.11"
}
labels = {
type = "db"
}
depends_on = [
hcloud_network_subnet.db_network_subnet
]
2022-11-07 04:53:09 +01:00
lifecycle {
ignore_changes = [
2023-02-07 23:11:14 +01:00
ssh_keys,
image
2022-11-07 04:53:09 +01:00
]
}
}
resource "hcloud_server" "backend1" {
2021-11-29 02:04:29 +01:00
name = "backend1"
image = data.hcloud_image.nixos_stable.id
server_type = "cpx21"
ssh_keys = [
2022-11-07 04:53:09 +01:00
hcloud_ssh_key.froidmpa-desktop.id
]
keep_disk = true
2023-02-07 23:11:14 +01:00
location = "fsn1"
network {
network_id = hcloud_network.private_network.id
2021-11-29 02:04:29 +01:00
ip = "10.0.1.1"
}
labels = {
type = "backend"
}
depends_on = [
hcloud_network_subnet.db_network_subnet
]
2022-11-07 04:53:09 +01:00
lifecycle {
ignore_changes = [
2023-02-07 23:11:14 +01:00
ssh_keys,
image
2022-11-07 04:53:09 +01:00
]
}
}