Adds terraform/edge, a root module with two providers: - Cloudflare 5.28.1: CNAMEs to the existing tunnel, plus an opt-in resource that can take the tunnel ingress list over when manage_tunnel_config is true. It is off by default because that resource REPLACES the whole list, and the tunnel is remotely managed from the dashboard today. - Tencent Cloud 1.83.38: VPC, subnet, security group with three rules, key pair, one CVM relay with cloud-init (WireGuard listener, forwarding sysctls, Caddy), and DNSPod A records for the .cn hostnames. The design keeps the homelab inbound-free: the relay terminates TLS in China and forwards over a WireGuard tunnel the cluster dials outbound. Cloudflare keeps serving every existing hostname untouched. Verified: terraform init succeeds for both providers, fmt clean, validate reports 0 errors, and plan resolves to 10 creates with placeholder variables. Provider-side name validation caught a real bug during that run: key pair and security group names allow only letters, digits and underscore, so the derived names use underscores. Not applied. Credentials come from CLOUDFLARE_API_TOKEN, TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY; the WireGuard private key is TF_VAR only. State is local and git-ignored like terraform/zitadel. Blocked on facts this module cannot invent: the real .cn domain, whether it has an ICP filing, the CVM image ID, the operator CIDR, and the homelab WireGuard public key.
41 lines
1.6 KiB
Terraform
41 lines
1.6 KiB
Terraform
output "cloudflare_records" {
|
|
description = "Hostnames now managed in the Cloudflare zone."
|
|
value = sort(keys(cloudflare_dns_record.tunnel))
|
|
}
|
|
|
|
output "tunnel_config_managed" {
|
|
description = "Whether Terraform owns the tunnel ingress list. False means the dashboard still does."
|
|
value = var.manage_tunnel_config
|
|
}
|
|
|
|
output "relay_public_ip" {
|
|
description = "Public address of the Tencent relay. Point the .cn DNS at it, or let the module do it."
|
|
value = tencentcloud_instance.relay.public_ip
|
|
}
|
|
|
|
output "china_hostnames" {
|
|
description = "Fully qualified China hostnames served by the relay."
|
|
value = [for host in var.china_hostnames : "${host}.${var.china_domain}"]
|
|
}
|
|
|
|
output "wireguard_peer" {
|
|
description = "Peer stanza for the homelab side. Add it to the cluster's wg0.conf; the relay already trusts this public key."
|
|
value = <<-EOT
|
|
[Peer]
|
|
PublicKey = <relay public key; see /etc/wireguard/wg0.conf on the relay>
|
|
Endpoint = ${tencentcloud_instance.relay.public_ip}:${var.wireguard_port}
|
|
AllowedIPs = ${var.wireguard_relay_address}
|
|
PersistentKeepalive = 25
|
|
EOT
|
|
}
|
|
|
|
output "next_manual_steps" {
|
|
description = "What this module cannot do for you."
|
|
value = [
|
|
"Confirm the ICP filing for ${var.china_domain} if the relay is in a mainland region.",
|
|
"Issue a certificate for the China hostnames on the relay (Caddy ACME needs the DNS-01 challenge for a .cn domain).",
|
|
"Run a WireGuard peer in the cluster that dials ${tencentcloud_instance.relay.public_ip}:${var.wireguard_port}.",
|
|
"Add the .cn origins to the OIDC client redirect URIs before any China user logs in.",
|
|
]
|
|
}
|