-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.tf
More file actions
98 lines (88 loc) · 3.2 KB
/
Copy pathmain.tf
File metadata and controls
98 lines (88 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
////////////////////////////////////////////////////////////////////////////////////////
// TERRAFORM PROVIDERS & BACKEND
////////////////////////////////////////////////////////////////////////////////////////
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.28"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
hcloud = {
source = "hetznercloud/hcloud"
version = "~> 1.42.1"
}
}
}
terraform {
backend "s3" {
skip_credentials_validation = true
skip_metadata_api_check = true
endpoints = { s3 = "https://fra1.digitaloceanspaces.com" }
skip_requesting_account_id = true
skip_s3_checksum = true
region = "us-east-1"
bucket = "merge-testnets"
key = "infrastructure/devnet-0/terraform.tfstate"
}
}
provider "digitalocean" {
http_retry_max = 20
}
provider "cloudflare" {
api_token = var.cloudflare_api_token
}
provider "hcloud" {
token = var.glamsterdam_hcloud_token
}
////////////////////////////////////////////////////////////////////////////////////////
// VARIABLES
////////////////////////////////////////////////////////////////////////////////////////
variable "cloudflare_api_token" {
type = string
sensitive = true
description = "Cloudflare API Token"
}
variable "glamsterdam_hcloud_token" {
type = string
sensitive = true
default = ""
description = "Hetzner Cloud API Token (optional if not using Hetzner)"
}
variable "ethereum_network" {
type = string
default = "glamsterdam-devnet-0"
}
variable "base_cidr_block" {
default = "10.9.0.0/16"
}
////////////////////////////////////////////////////////////////////////////////////////
// LOCALS
////////////////////////////////////////////////////////////////////////////////////////
locals {
# Normalize node entries with defaults and calculate starting index for continuous numbering
nodes_normalized = [
for idx, node in var.nodes : {
name = node.name
count = node.count
cloud = node.cloud
validator_start = try(node.validator_start, 0)
validator_end = try(node.validator_end, 0)
size = try(node.size, null)
region = try(node.region, null)
location = try(node.location, try(node.region, null))
supernode = try(node.supernode, null)
ipv6 = try(node.ipv6, true)
ipv4_enabled = try(node.ipv4_enabled, true)
ipv6_enabled = try(node.ipv6_enabled, true)
# Calculate starting index: sum of counts from all previous entries with same name
start_index = sum(concat([for i, n in var.nodes : n.count if i < idx && n.name == node.name], [0]))
}
]
# Filter by cloud provider (only nodes with count > 0)
digitalocean_nodes = [for n in local.nodes_normalized : n if n.cloud == "digitalocean" && n.count > 0]
hetzner_nodes = [for n in local.nodes_normalized : n if n.cloud == "hetzner" && n.count > 0]
}