Pijus Kamandulis ea46b13a17 Initial commit
2022-01-28 18:02:57 +02:00

106 lines
2.0 KiB
HCL

terraform {
required_providers {
scaleway = {
source = "scaleway/scaleway"
}
}
required_version = ">= 0.13"
}
provider "scaleway" {
zone = var.zone
region = var.region
}
resource "scaleway_instance_ip" "public_ip" {
project_id = var.project_id
}
resource "scaleway_instance_volume" "volume" {
name = "v7days"
project_id = var.project_id
size_in_gb = var.data_volume_size
type = "l_ssd"
lifecycle {
prevent_destroy = true
}
}
resource "scaleway_instance_security_group" "security_group" {
name = "sg7daysPL"
project_id = var.project_id
inbound_default_policy = "drop"
outbound_default_policy = "accept"
inbound_rule {
action = "accept"
port = "22"
}
inbound_rule {
action = "accept"
port = "80"
}
inbound_rule {
action = "accept"
port = "443"
}
inbound_rule {
action = "accept"
port = "26900"
protocol = "TCP"
}
inbound_rule {
action = "accept"
port = "26900"
protocol = "UDP"
}
inbound_rule {
action = "accept"
port = "26901"
protocol = "TCP"
}
inbound_rule {
action = "accept"
port = "26901"
protocol = "UDP"
}
inbound_rule {
action = "accept"
port = "26902"
protocol = "TCP"
}
inbound_rule {
action = "accept"
port = "26902"
protocol = "UDP"
}
}
resource "scaleway_instance_server" "instance_server" {
name = "i7daysPL"
project_id = var.project_id
type = var.instance_type
image = var.instance_image
tags = ["game", "terraform"]
ip_id = scaleway_instance_ip.public_ip.id
additional_volume_ids = [scaleway_instance_volume.volume.id]
root_volume {
size_in_gb = var.instance_volume_size
}
security_group_id = scaleway_instance_security_group.security_group.id
}