Skip to content

Commit 1e90229

Browse files
committed
infra: add postgres secondary
1 parent a82e87c commit 1e90229

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

infra/aggregation_mode/terraform/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ module "postgres_monitor" {
1010
module "postgres_primary" {
1111
source = "./postgres_primary"
1212
}
13+
14+
module "postgres_secondary" {
15+
source = "./postgres_secondary"
16+
}

infra/aggregation_mode/terraform/postgres_primary/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variable "zone" {
77
variable "offer_name" {
88
description = "Name of the bare metal server offer"
99
type = string
10-
default = "EM-A116X-SSD"
10+
default = "EM-A410X-SSD" # Set correct server offer
1111
}
1212

1313
variable "server_name" {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
terraform {
2+
required_providers {
3+
scaleway = {
4+
source = "scaleway/scaleway"
5+
}
6+
}
7+
}
8+
9+
# Get available bare metal offer
10+
data "scaleway_baremetal_offer" "offer" {
11+
zone = var.zone
12+
name = var.offer_name
13+
subscription_period = "hourly"
14+
}
15+
16+
# Get Debian 12 OS
17+
data "scaleway_baremetal_os" "debian12" {
18+
os_id = "83640d93-a0b8-45ad-9c9f-30cae48380a4"
19+
}
20+
21+
# Upload SSH key
22+
resource "scaleway_iam_ssh_key" "main" {
23+
name = var.ssh_key_name
24+
public_key = file(var.ssh_public_key_path)
25+
}
26+
27+
# Create bare metal server with hourly billing
28+
resource "scaleway_baremetal_server" "postgres_secondary" {
29+
name = var.server_name
30+
offer = data.scaleway_baremetal_offer.offer.offer_id
31+
zone = var.zone
32+
description = var.description
33+
34+
# Install OS
35+
os = data.scaleway_baremetal_os.debian12.os_id
36+
37+
# Attach SSH key
38+
ssh_key_ids = [scaleway_iam_ssh_key.main.id]
39+
40+
# Cloud-init configuration
41+
cloud_init = templatefile("${path.module}/../cloudinit/scaleway-cloud-init.yaml", {
42+
hostname = var.hostname
43+
ssh_public_key = trimspace(file(var.ssh_public_key_path))
44+
})
45+
46+
tags = var.tags
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
variable "zone" {
2+
description = "Scaleway zone"
3+
type = string
4+
default = "nl-ams-1"
5+
}
6+
7+
variable "offer_name" {
8+
description = "Name of the bare metal server offer"
9+
type = string
10+
default = "EM-A315X-SSD "
11+
}
12+
13+
variable "server_name" {
14+
description = "Name of the bare metal server"
15+
type = string
16+
default = "postgres-secondary"
17+
}
18+
19+
variable "hostname" {
20+
description = "Hostname for the server"
21+
type = string
22+
default = "postgres-secondary"
23+
}
24+
25+
variable "description" {
26+
description = "Description of the server"
27+
type = string
28+
default = "PostgreSQL secondary server"
29+
}
30+
31+
variable "ssh_key_name" {
32+
description = "Name for the SSH key in Scaleway"
33+
type = string
34+
default = "postgres-secondary-key"
35+
}
36+
37+
variable "ssh_public_key_path" {
38+
description = "Path to the SSH public key file"
39+
type = string
40+
default = "~/.ssh/scaleway.pem.pub"
41+
}
42+
43+
variable "tags" {
44+
description = "Tags to apply to the server"
45+
type = list(string)
46+
default = ["postgres", "secondary"]
47+
}

0 commit comments

Comments
 (0)