File tree Expand file tree Collapse file tree 10 files changed +100
-16
lines changed
infra/aggregation_mode/terraform Expand file tree Collapse file tree 10 files changed +100
-16
lines changed Original file line number Diff line number Diff line change @@ -36,3 +36,7 @@ packages:
3636
3737runcmd :
3838 - loginctl enable-linger app
39+ # Tailscale installation https://tailscale.com/kb/1293/cloud-init
40+ - curl -fsSL https://tailscale.com/install.sh | sh
41+ - tailscale up --ssh --advertise-tags=tag:server --auth-key=${tailscale_auth_key}
42+ - tailscale set --auto-update
Original file line number Diff line number Diff line change @@ -36,3 +36,7 @@ packages:
3636
3737runcmd :
3838 - loginctl enable-linger app
39+ # Tailscale installation https://tailscale.com/kb/1293/cloud-init
40+ - curl -fsSL https://tailscale.com/install.sh | sh
41+ - tailscale up --ssh --advertise-tags=tag:server --auth-key=${tailscale_auth_key}
42+ - tailscale set --auto-update
Original file line number Diff line number Diff line change @@ -2,15 +2,19 @@ provider "aws" {
22 region = " us-east-2"
33}
44
5+ provider "tailscale" {
6+ # Configure via environment variables:
7+ # TAILSCALE_API_KEY
8+ }
59
610module "postgres_monitor" {
711 source = " ./postgres_monitor"
812}
913
10- module "postgres_primary" {
11- source = " ./postgres_primary"
12- }
14+ # module "postgres_primary" {
15+ # source = "./postgres_primary"
16+ # }
1317
14- module "postgres_secondary" {
15- source = " ./postgres_secondary"
16- }
18+ # module "postgres_secondary" {
19+ # source = "./postgres_secondary"
20+ # }
Original file line number Diff line number Diff line change 1- output "postgres_monitor_instance_hostname" {
2- description = " Private DNS name of the EC2 instance."
3- value = module. postgres_monitor . instance_hostname
4- }
5-
61output "postgres_monitor_public_ip" {
7- description = " Public IP address of the EC2 instance ."
2+ description = " Public IP address of the Postgres Monitor ."
83 value = module. postgres_monitor . public_ip
94}
5+
6+ # output "postgres_primary_public_ip" {
7+ # description = "Public IP address of the Postgres Primary."
8+ # value = module.postgres_primary.public_ip
9+ # }
10+ #
11+ # output "postgres_secondary_public_ip" {
12+ # description = "Public IP address of the Postgres Secondary."
13+ # value = module.postgres_secondary.public_ip
14+ # }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ tailscale = {
4+ source = " tailscale/tailscale"
5+ }
6+ }
7+ }
8+
9+ # Create ephemeral Tailscale auth key
10+ resource "tailscale_tailnet_key" "postgres_monitor" {
11+ reusable = false
12+ ephemeral = true
13+ preauthorized = true
14+ expiry = 3600
15+ description = " Ephemeral key for postgres-monitor"
16+ tags = [" tag:server" ]
17+ }
18+
119# Upload existing SSH public key to AWS
220resource "aws_key_pair" "ssh_key" {
321 key_name = var. ssh_key_name
@@ -58,8 +76,9 @@ resource "aws_instance" "postgres_monitor" {
5876 vpc_security_group_ids = [aws_security_group . ssh_access . id ]
5977
6078 user_data = templatefile (" ${ path . module } /../cloudinit/postgres-monitor-cloud-init.yaml" , {
61- hostname = var.hostname
62- ssh_public_key = trimspace (file (var. ssh_public_key_path ))
79+ hostname = var.hostname
80+ ssh_public_key = trimspace (file (var. ssh_public_key_path ))
81+ tailscale_auth_key = tailscale_tailnet_key.postgres_monitor.key
6382 })
6483
6584 user_data_replace_on_change = true
Original file line number Diff line number Diff line change @@ -3,9 +3,22 @@ terraform {
33 scaleway = {
44 source = " scaleway/scaleway"
55 }
6+ tailscale = {
7+ source = " tailscale/tailscale"
8+ }
69 }
710}
811
12+ # Create ephemeral Tailscale auth key
13+ resource "tailscale_tailnet_key" "postgres_primary" {
14+ reusable = false
15+ ephemeral = true
16+ preauthorized = true
17+ expiry = 3600
18+ description = " Ephemeral key for postgres-primary"
19+ tags = [" tag:server" ]
20+ }
21+
922# Get available bare metal offer
1023data "scaleway_baremetal_offer" "offer" {
1124 zone = var. zone
@@ -41,8 +54,9 @@ resource "scaleway_baremetal_server" "postgres_primary" {
4154
4255 # Cloud-init configuration
4356# cloud_init = templatefile("${path.module}/../cloudinit/scaleway-cloud-init.yaml", {
44- # hostname = var.hostname
45- # ssh_public_key = trimspace(file(var.ssh_public_key_path))
57+ # hostname = var.hostname
58+ # ssh_public_key = trimspace(file(var.ssh_public_key_path))
59+ # tailscale_auth_key = tailscale_tailnet_key.postgres_primary.key
4660# })
4761
4862 tags = var. tags
Original file line number Diff line number Diff line change 1+ output public_ip {
2+ description = " Public IP address of the Postgres Primary."
3+ value = scaleway_baremetal_server. postgres_primary . ips
4+ }
Original file line number Diff line number Diff line change 1+ output public_ip {
2+ description = " Public IP address of the Postgres Secondary."
3+ value = scaleway_baremetal_server. postgres_secondary . ips
4+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ terraform {
88 source = " scaleway/scaleway"
99 version = " 2.64.0"
1010 }
11+ tailscale = {
12+ source = " tailscale/tailscale"
13+ version = " 0.24.0"
14+ }
1115 }
1216
1317 required_version = " >= 1.2"
You can’t perform that action at this time.
0 commit comments