Skip to content

Commit cc3383d

Browse files
NathanFlurryAngelOnFira
authored andcommitted
feat(infra): auto-create dev tunnel & public ip
1 parent 35f43a4 commit cc3383d

File tree

23 files changed

+178
-106
lines changed

23 files changed

+178
-106
lines changed

Taskfile.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

infra/dev-tunnel/Taskfile.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

infra/dev-tunnel/providers.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

infra/dev-tunnel/vars.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

infra/tf/dev_tunnel/dev_tunnel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dev_tunnel/

infra/dev-tunnel/main.tf renamed to infra/tf/dev_tunnel/main.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ terraform {
1111
}
1212
}
1313

14-
output "ip" {
15-
value = linode_instance.tunnel.ip_address
14+
module "secrets" {
15+
source = "../modules/secrets"
16+
17+
keys = [
18+
"linode/token",
19+
]
1620
}
21+

infra/tf/dev_tunnel/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "tunnel_public_ip" {
2+
value = linode_instance.tunnel.ip_address
3+
}

infra/tf/dev_tunnel/providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "linode" {
2+
token = module.secrets.values["linode/token"]
3+
}
Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
dev_tunnel_name = "dev-tunnel-${random_string.tunnel_suffix.result}"
2+
dev_tunnel_name = "${var.namespace}-dev-tunnel"
33
}
44

55
resource "random_string" "tunnel_suffix" {
@@ -11,9 +11,9 @@ resource "random_string" "tunnel_suffix" {
1111
}
1212

1313
resource "random_password" "password" {
14-
length = 16
15-
special = true
16-
override_special = "_%@"
14+
length = 16
15+
special = true
16+
override_special = "_%@"
1717
}
1818

1919
resource "linode_instance" "tunnel" {
@@ -23,7 +23,7 @@ resource "linode_instance" "tunnel" {
2323
type = "g6-nanode-1"
2424
authorized_keys = [trimspace(tls_private_key.ssh_key.public_key_openssh)]
2525
root_pass = random_password.password.result
26-
tags = ["dev-tunnel"]
26+
tags = ["rivet-${var.namespace}", "${var.namespace}-dev-tunnel"]
2727
}
2828

2929
resource "linode_firewall" "tunnel_firewall" {
@@ -45,38 +45,44 @@ resource "linode_firewall" "tunnel_firewall" {
4545
label = "http"
4646
action = "ACCEPT"
4747
protocol = "TCP"
48-
ports = "80"
48+
ports = var.api_http_port
4949
ipv4 = ["0.0.0.0/0"]
5050
ipv6 = ["::/0"]
5151
}
5252

53-
inbound {
54-
label = "https"
55-
action = "ACCEPT"
56-
protocol = "TCP"
57-
ports = "443"
58-
ipv4 = ["0.0.0.0/0"]
59-
ipv6 = ["::/0"]
53+
dynamic "inbound" {
54+
for_each = var.api_https_port != null ? [1] : []
55+
content {
56+
label = "https"
57+
action = "ACCEPT"
58+
protocol = "TCP"
59+
ports = var.api_https_port
60+
ipv4 = ["0.0.0.0/0"]
61+
ipv6 = ["::/0"]
62+
}
6063
}
6164

6265
inbound {
6366
label = "tunnel"
6467
action = "ACCEPT"
6568
protocol = "TCP"
66-
ports = "5000"
69+
ports = var.tunnel_port
6770
ipv4 = ["0.0.0.0/0"]
6871
ipv6 = ["::/0"]
6972
}
7073

71-
inbound {
72-
label = "minio"
73-
action = "ACCEPT"
74-
protocol = "TCP"
75-
ports = "9000"
76-
ipv4 = ["0.0.0.0/0"]
77-
ipv6 = ["::/0"]
74+
dynamic "inbound" {
75+
for_each = var.minio_port != null ? [1] : []
76+
content {
77+
label = "minio"
78+
action = "ACCEPT"
79+
protocol = "TCP"
80+
ports = var.minio_port
81+
ipv4 = ["0.0.0.0/0"]
82+
ipv6 = ["::/0"]
83+
}
7884
}
7985

80-
linodes = [linode_instance.tunnel.id]
86+
linodes = [linode_instance.tunnel.id]
8187
}
82-
88+
File renamed without changes.

0 commit comments

Comments
 (0)