feat(edge): Terraform for the China-facing relay and Cloudflare DNS
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.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# terraform/edge — the China-facing edge, plus DNS ownership for the existing zone
|
||||
#
|
||||
# Purpose: give users in mainland China a short, stable path to the homelab
|
||||
# without touching the Cloudflare path that serves everyone else.
|
||||
#
|
||||
# China user -> <service>.<china_domain> -> Tencent CVM (this module)
|
||||
# -> WireGuard tunnel -> ingress-nginx (192.168.1.160) -> service
|
||||
#
|
||||
# Everyone else -> Cloudflare -> cloudflared tunnel -> same ingress (unchanged)
|
||||
#
|
||||
# The homelab still opens no inbound port: the tunnel is established outbound
|
||||
# from the cluster to the CVM.
|
||||
#
|
||||
# Credentials come from the environment, never from a file in git:
|
||||
# export CLOUDFLARE_API_TOKEN=...
|
||||
# export TENCENTCLOUD_SECRET_ID=...
|
||||
# export TENCENTCLOUD_SECRET_KEY=...
|
||||
# terraform -chdir=terraform/edge init
|
||||
# terraform -chdir=terraform/edge plan -var china_domain=example.cn ...
|
||||
#
|
||||
# State is local and git-ignored, same as terraform/zitadel. It carries no
|
||||
# credential today, but it will once InstanceData or certificates are added, so
|
||||
# treat it as a secret and move it to MinIO before a second operator applies.
|
||||
terraform {
|
||||
required_version = ">= 1.6.0"
|
||||
|
||||
required_providers {
|
||||
cloudflare = {
|
||||
source = "cloudflare/cloudflare"
|
||||
version = "5.28.1"
|
||||
}
|
||||
tencentcloud = {
|
||||
source = "tencentcloudstack/tencentcloud"
|
||||
version = "1.83.38"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "cloudflare" {
|
||||
api_token = var.cloudflare_api_token
|
||||
}
|
||||
|
||||
provider "tencentcloud" {
|
||||
secret_id = var.tencent_secret_id
|
||||
secret_key = var.tencent_secret_key
|
||||
region = var.tencent_region
|
||||
}
|
||||
Reference in New Issue
Block a user