Files
ovh_gridscale_test_task/resources.tf
T

165 lines
3.8 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" {
name = "public_ipv4"
}
resource "gridscale_ipv6" "public_ipv6" {
name = "public_ipv6"
}
resource "gridscale_ipv4" "public_ipv4_monitoring" {
name = "public_ipv4_monitoring"
}
resource "gridscale_ipv6" "public_ipv6_monitoring" {
name = "public_ipv6_monitoring"
}
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_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"
}
}
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.id
ipv6 = gridscale_ipv6.public_ipv6.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_v4_in {
order = 10
protocol = "tcp"
action = "accept"
dst_port = 80
comment = "Allow HTTP 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"
}
}
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"
}
}