code-server-test/main.tf

55 lines
974 B
Terraform
Raw Normal View History

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:32:46 +01:00
resource "hcloud_server" "ubuntu_server" {
2021-12-01 12:00:43 +01:00
name = "jk-test1"
image = "ubuntu-20.04"
server_type = "cpx11"
network {
2021-12-01 12:32:46 +01:00
network_id = hcloud_network.network.id
2021-12-01 12:00:43 +01:00
}
2021-12-01 12:36:12 +01:00
user_data = file("cloud-init-sv")
2021-12-01 12:00:43 +01:00
depends_on = [
2021-12-01 12:32:46 +01:00
hcloud_server.ubuntu_mysql
2021-12-01 12:00:43 +01:00
]
}
2021-12-01 12:32:46 +01:00
resource "hcloud_server" "ubuntu_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"
2021-12-01 12:32:46 +01:00
}