2021-03-23 22:09:48 +00:00
|
|
|
locals {
|
|
|
|
casey_open_ports = toset([
|
|
|
|
"80/tcp",
|
|
|
|
"443/tcp",
|
|
|
|
"51820/udp",
|
|
|
|
"4242/tcp",
|
|
|
|
"8448/tcp",
|
|
|
|
"6328/udp"
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-23 21:22:31 +00:00
|
|
|
resource "vultr_instance" "casey" {
|
|
|
|
plan = "" # On a plan unsupported by API
|
|
|
|
region = "lhr"
|
2020-02-22 22:13:44 +00:00
|
|
|
hostname = "casey"
|
|
|
|
firewall_group_id = vultr_firewall_group.casey.id
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "vultr_firewall_group" "casey" {
|
|
|
|
description = "casey"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "vultr_firewall_rule" "casey_ping" {
|
|
|
|
firewall_group_id = vultr_firewall_group.casey.id
|
|
|
|
protocol = "icmp"
|
2021-03-23 21:22:31 +00:00
|
|
|
ip_type = "v4"
|
|
|
|
subnet = "0.0.0.0"
|
|
|
|
subnet_size = 0
|
2020-02-22 22:13:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-23 22:09:48 +00:00
|
|
|
resource "vultr_firewall_rule" "casey_pingv6" {
|
2020-02-22 22:13:44 +00:00
|
|
|
firewall_group_id = vultr_firewall_group.casey.id
|
2021-03-23 22:09:48 +00:00
|
|
|
protocol = "icmp"
|
|
|
|
ip_type = "v6"
|
|
|
|
subnet = "::"
|
2021-03-23 21:22:31 +00:00
|
|
|
subnet_size = 0
|
2020-02-22 22:13:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-23 22:09:48 +00:00
|
|
|
resource "vultr_firewall_rule" "casey_v4" {
|
|
|
|
for_each = local.casey_open_ports
|
2020-02-22 22:13:44 +00:00
|
|
|
|
|
|
|
firewall_group_id = vultr_firewall_group.casey.id
|
2021-03-23 22:09:48 +00:00
|
|
|
protocol = split("/", each.value)[1]
|
|
|
|
port = split("/", each.value)[0]
|
2021-03-23 21:22:31 +00:00
|
|
|
ip_type = "v4"
|
|
|
|
subnet = "0.0.0.0"
|
|
|
|
subnet_size = 0
|
2020-02-22 22:13:44 +00:00
|
|
|
}
|
|
|
|
|
2021-03-23 22:09:48 +00:00
|
|
|
resource "vultr_firewall_rule" "casey_v6" {
|
|
|
|
for_each = local.casey_open_ports
|
2020-04-07 18:43:40 +01:00
|
|
|
|
2021-01-25 21:53:04 +00:00
|
|
|
firewall_group_id = vultr_firewall_group.casey.id
|
2021-03-23 22:09:48 +00:00
|
|
|
protocol = split("/", each.value)[1]
|
|
|
|
port = split("/", each.value)[0]
|
|
|
|
ip_type = "v6"
|
|
|
|
subnet = "::"
|
2021-03-23 21:22:31 +00:00
|
|
|
subnet_size = 0
|
2021-01-25 21:53:04 +00:00
|
|
|
}
|