kedge/terraform/modules/wireguard-topology/main.tf
Tyler King 6058e62348 Initial commit: Kedge network automation platform
Go-based network automation with YANG models, gRPC, Ansible,
Terraform, and Kubernetes integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 12:09:30 -05:00

38 lines
824 B
HCL

terraform {
required_providers {
local = {
source = "hashicorp/local"
version = "~> 2.5"
}
}
}
# Declarative WireGuard mesh peer relationships.
# Generates peer configuration for each node in the mesh.
locals {
peer_pairs = flatten([
for i, site_a in var.sites : [
for j, site_b in var.sites : {
from = site_a
to = site_b
} if i < j
]
])
}
resource "local_file" "peer_config" {
for_each = { for site in var.sites : site.name => site }
filename = "${var.output_dir}/${each.key}-peers.json"
content = jsonencode({
site_id = each.value.name
peers = [
for site in var.sites : {
public_key = site.public_key
endpoint = site.endpoint
allowed_ips = site.allowed_ips
} if site.name != each.key
]
})
}