229 lines
5.3 KiB
Terraform
229 lines
5.3 KiB
Terraform
resource "gridscale_network" "network_internal"{
|
|
name = "network_internal"
|
|
dhcp_active = true
|
|
dhcp_gateway = "192.168.121.1"
|
|
dhcp_dns = "192.168.121.2"
|
|
dhcp_range = "192.168.121.0/27"
|
|
dhcp_reserved_subnet = ["192.168.121.0/31"]
|
|
}
|
|
|
|
resource "gridscale_ipv4" "public_ipv4_caddy" {
|
|
name = "public_ipv4_caddy"
|
|
}
|
|
|
|
resource "gridscale_ipv6" "public_ipv6_caddy" {
|
|
name = "public_ipv6_caddy"
|
|
}
|
|
|
|
resource "gridscale_ipv4" "public_ipv4_monitoring" {
|
|
name = "public_ipv4_monitoring"
|
|
}
|
|
|
|
resource "gridscale_ipv6" "public_ipv6_monitoring" {
|
|
name = "public_ipv6_monitoring"
|
|
}
|
|
|
|
resource "gridscale_ipv4" "public_ipv4_nginx" {
|
|
name = "public_ipv4_nginx"
|
|
}
|
|
|
|
resource "gridscale_ipv6" "public_ipv6_nginx" {
|
|
name = "public_ipv6_nginx"
|
|
}
|
|
|
|
data "gridscale_template" "template_debian_13" {
|
|
name = "Debian 13"
|
|
}
|
|
|
|
resource "gridscale_sshkey" "sshkey_richard" {
|
|
name = "Richard SSH Key"
|
|
sshkey = file("~/.ssh/id_ed25519.pub")
|
|
}
|
|
|
|
resource "gridscale_storage" "storage_caddy" {
|
|
name = "storage_caddy"
|
|
storage_type = "storage"
|
|
capacity = 20
|
|
template {
|
|
sshkeys = [gridscale_sshkey.sshkey_richard.id]
|
|
template_uuid = data.gridscale_template.template_debian_13.id
|
|
hostname = var.caddy_hostname
|
|
}
|
|
}
|
|
|
|
resource "gridscale_server" "server_caddy" {
|
|
name = var.caddy_hostname
|
|
cores = 2
|
|
memory = 1
|
|
power = true
|
|
storage {
|
|
object_uuid = gridscale_storage.storage_caddy.id
|
|
}
|
|
network {
|
|
# Public network
|
|
object_uuid = "5557a73b-31ee-4b1f-aa15-7789ad6ae04c"
|
|
rules_v4_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 22
|
|
comment = "Allow SSH access"
|
|
}
|
|
rules_v4_in {
|
|
order = 10
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 80
|
|
comment = "Allow HTTP access"
|
|
}
|
|
rules_v4_in {
|
|
order = 15
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 443
|
|
comment = "Allow HTTPS access"
|
|
}
|
|
rules_v6_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 22
|
|
comment = "Allow SSHv6 access"
|
|
}
|
|
rules_v6_in {
|
|
order = 10
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 80
|
|
comment = "Allow HTTPv6 access"
|
|
}
|
|
rules_v6_in {
|
|
order = 15
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 443
|
|
comment = "Allow HTTPSv6 access"
|
|
}
|
|
}
|
|
network {
|
|
# Private network
|
|
object_uuid = gridscale_network.network_internal.id
|
|
rules_v4_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 2019
|
|
comment = "Allow Prometheus access"
|
|
src_cidr = "192.168.121.0/27"
|
|
}
|
|
}
|
|
ipv4 = gridscale_ipv4.public_ipv4_caddy.id
|
|
ipv6 = gridscale_ipv6.public_ipv6_caddy.id
|
|
timeouts {
|
|
create = "10m"
|
|
}
|
|
}
|
|
|
|
resource "gridscale_storage" "storage_monitoring" {
|
|
name = "storage_monitoring"
|
|
storage_type = "storage"
|
|
capacity = 20
|
|
template {
|
|
sshkeys = [gridscale_sshkey.sshkey_richard.id]
|
|
template_uuid = data.gridscale_template.template_debian_13.id
|
|
hostname = var.monitoring_hostname
|
|
}
|
|
}
|
|
|
|
resource "gridscale_server" "server_monitoring" {
|
|
name = var.monitoring_hostname
|
|
cores = 2
|
|
memory = 1
|
|
power = true
|
|
storage {
|
|
object_uuid = gridscale_storage.storage_monitoring.id
|
|
}
|
|
network {
|
|
# Public Network
|
|
object_uuid = "5557a73b-31ee-4b1f-aa15-7789ad6ae04c"
|
|
rules_v4_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 22
|
|
comment = "Allow SSH access"
|
|
}
|
|
rules_v6_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 22
|
|
comment = "Allow SSHv6 access"
|
|
}
|
|
}
|
|
network {
|
|
# Private Network
|
|
object_uuid = gridscale_network.network_internal.id
|
|
}
|
|
ipv4 = gridscale_ipv4.public_ipv4_monitoring.id
|
|
ipv6 = gridscale_ipv6.public_ipv6_monitoring.id
|
|
timeouts {
|
|
create = "10m"
|
|
}
|
|
}
|
|
|
|
|
|
resource "gridscale_storage" "storage_nginx" {
|
|
name = "storage_nginx"
|
|
storage_type = "storage"
|
|
capacity = 20
|
|
template {
|
|
sshkeys = [gridscale_sshkey.sshkey_richard.id]
|
|
template_uuid = data.gridscale_template.template_debian_13.id
|
|
hostname = var.nginx_hostname
|
|
}
|
|
}
|
|
|
|
resource "gridscale_server" "server_nginx" {
|
|
name = var.nginx_hostname
|
|
cores = 2
|
|
memory = 1
|
|
power = true
|
|
storage {
|
|
object_uuid = gridscale_storage.storage_nginx.id
|
|
}
|
|
network {
|
|
# Public Network
|
|
object_uuid = "5557a73b-31ee-4b1f-aa15-7789ad6ae04c"
|
|
rules_v4_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 22
|
|
comment = "Allow SSH access"
|
|
}
|
|
rules_v6_in {
|
|
order = 0
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 22
|
|
comment = "Allow SSHv6 access"
|
|
}
|
|
}
|
|
network {
|
|
# Private Network
|
|
object_uuid = gridscale_network.network_internal.id
|
|
rules_v4_in {
|
|
order = 10
|
|
protocol = "tcp"
|
|
action = "accept"
|
|
dst_port = 80
|
|
comment = "Allow HTTP access for Loadbalancer"
|
|
}
|
|
}
|
|
ipv4 = gridscale_ipv4.public_ipv4_nginx.id
|
|
ipv6 = gridscale_ipv6.public_ipv6_nginx.id
|
|
timeouts {
|
|
create = "10m"
|
|
}
|
|
} |