2021-12-01 12:00:43 +01:00
|
|
|
terraform {
|
|
|
|
required_providers {
|
2021-12-01 12:23:40 +01:00
|
|
|
hcloud = {
|
2021-12-01 12:00:43 +01:00
|
|
|
source = "hetznercloud/hcloud"
|
|
|
|
version = "1.32.1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "token" {
|
|
|
|
type = string
|
|
|
|
}
|
|
|
|
|
2021-12-01 12:23:40 +01:00
|
|
|
provider "hcloud" {
|
2021-12-01 12:00:43 +01:00
|
|
|
token = var.token
|
|
|
|
}
|
|
|
|
|
2021-12-01 12:23:40 +01:00
|
|
|
resource "hcloud_sv" "ubuntu" {
|
2021-12-01 12:00:43 +01:00
|
|
|
name = "jk-test1"
|
|
|
|
image = "ubuntu-20.04"
|
|
|
|
server_type = "cpx11"
|
|
|
|
|
|
|
|
network {
|
|
|
|
network_id = hc_network.network.id
|
|
|
|
}
|
|
|
|
|
|
|
|
user_data = file("cloud-init-sv")
|
|
|
|
|
|
|
|
depends_on = [
|
|
|
|
hc_sv.mysql
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2021-12-01 12:23:40 +01:00
|
|
|
resource "hcloud_sv" "mysql" {
|
2021-12-01 12:00:43 +01:00
|
|
|
name = "jk-test2"
|
|
|
|
image = "ubuntu-20.04"
|
|
|
|
server_type = "cpx11"
|
|
|
|
user_data = file("cloud-init-db")
|
|
|
|
|
|
|
|
network {
|
2021-12-01 12:23:40 +01:00
|
|
|
network_id = hcloud_network.network.id
|
2021-12-01 12:00:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-01 12:23:40 +01:00
|
|
|
resource "hcloud_network" "network" {
|
2021-12-01 12:00:43 +01:00
|
|
|
name = "jk-test3"
|
|
|
|
ip_range = "10.0.1.0/24"
|
|
|
|
}
|
|
|
|
|
2021-12-01 12:23:40 +01:00
|
|
|
resource "hcloud_network_subnet" "subnet" {
|
|
|
|
network_id = hcloud_network.network.id
|
2021-12-01 12:00:43 +01:00
|
|
|
type = "cloud"
|
|
|
|
network_zone = "eu-central"
|
|
|
|
ip_range = "10.0.1.0/24"
|
|
|
|
}
|