infra/stacks/tuya-bridge/main.tf
Viktor Barzin 53657d9952 infra: document auth = "app|none" tier on every legacy ingress
Sweep through the 30+ stacks that predated the auth = "app" tier
and were tagged auth = "none" without a comment explaining why
they weren't behind Authentik. Each is now self-documenting at the
call site, so the tg-level anti-exposure guard passes and future
readers don't have to reverse-engineer the intent.

Flipped 6 stacks from "none" to "app" — their backends have their
own user auth and the new tier records that more accurately:
  - navidrome   (Subsonic user/password)
  - ntfy        (deny-all default + user.db tokens)
  - nextcloud   (WebDAV/CalDAV/CardDAV app passwords)
  - vaultwarden (Bitwarden-compatible token auth)
  - headscale   (OIDC + preauth keys for Tailscale nodes)
  - paperless-ngx (app-layer login + API tokens)

Kept "none" with a comment on the rest — they're genuinely public,
webhook receivers, native-protocol endpoints, OAuth callbacks, or
Anubis-fronted: authentik (×2 + guest outpost), beads-server (dolt),
claude-memory (bearer-token MCP), dawarich, ebooks/book-search-api,
fire-planner /api, forgejo (git/OCI native clients), frigate (HA
integration), immich/frame, insta2spotify /api, instagram-poster
(meta fetcher), k8s-portal, matrix (native bearer), monitoring×2
(HA REST scrapes), n8n (webhooks), nvidia, onlyoffice (JWT),
owntracks (HTTP Basic), postiz, privatebin (client-side enc),
rybbit (analytics tracker), send (E2E file drop), tuya-bridge
(API key), vault (own auth + CLI), webhook_handler, woodpecker
(forgejo webhooks + OAuth), xray (×3 VPN transports).

real-estate-crawler/main.tf:400 already had its comment from a
prior edit — not touched here.

No live state changes — auth = "app" produces the same middleware
chain as auth = "none" (verified earlier this session). This commit
is purely documentation + intent-tagging.
2026-05-11 19:25:48 +00:00

200 lines
5.1 KiB
HCL

variable "tls_secret_name" {
type = string
sensitive = true
}
resource "kubernetes_namespace" "tuya-bridge" {
metadata {
name = "tuya-bridge"
labels = {
"istio-injection" : "disabled"
tier = local.tiers.cluster
}
}
lifecycle {
# KYVERNO_LIFECYCLE_V1: goldilocks-vpa-auto-mode ClusterPolicy stamps this label on every namespace
ignore_changes = [metadata[0].labels["goldilocks.fairwinds.com/vpa-update-mode"]]
}
}
resource "kubernetes_manifest" "external_secret" {
manifest = {
apiVersion = "external-secrets.io/v1beta1"
kind = "ExternalSecret"
metadata = {
name = "tuya-bridge-secrets"
namespace = "tuya-bridge"
}
spec = {
refreshInterval = "15m"
secretStoreRef = {
name = "vault-kv"
kind = "ClusterSecretStore"
}
target = {
name = "tuya-bridge-secrets"
}
dataFrom = [{
extract = {
key = "tuya-bridge"
}
}]
}
}
depends_on = [kubernetes_namespace.tuya-bridge]
}
module "tls_secret" {
source = "../../modules/kubernetes/setup_tls_secret"
namespace = kubernetes_namespace.tuya-bridge.metadata[0].name
tls_secret_name = var.tls_secret_name
}
resource "kubernetes_deployment" "tuya-bridge" {
metadata {
name = "tuya-bridge"
namespace = kubernetes_namespace.tuya-bridge.metadata[0].name
labels = {
app = "tuya-bridge"
tier = local.tiers.cluster
}
annotations = {
"reloader.stakater.com/auto" = "true"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "tuya-bridge"
}
}
template {
metadata {
labels = {
app = "tuya-bridge"
}
}
spec {
container {
image = "viktorbarzin/tuya_bridge:latest"
name = "tuya-bridge"
port {
container_port = 8080
}
env {
name = "TINYTUYA_API_KEY"
value_from {
secret_key_ref {
name = "tuya-bridge-secrets"
key = "api_key"
}
}
}
env {
name = "TINYTUYA_API_SECRET"
value_from {
secret_key_ref {
name = "tuya-bridge-secrets"
key = "api_secret"
}
}
}
env {
name = "SERVICE_API_KEY" # used for auth the API endpoint
value_from {
secret_key_ref {
name = "tuya-bridge-secrets"
key = "service_secret"
}
}
}
env {
name = "SLACK_URL"
value_from {
secret_key_ref {
name = "tuya-bridge-secrets"
key = "slack_url"
}
}
}
liveness_probe {
http_get {
path = "/health"
port = 8080
}
initial_delay_seconds = 60
period_seconds = 30
timeout_seconds = 5
failure_threshold = 6
}
readiness_probe {
http_get {
path = "/health"
port = 8080
}
initial_delay_seconds = 10
period_seconds = 15
timeout_seconds = 5
failure_threshold = 2
}
resources {
requests = {
cpu = "10m"
memory = "256Mi"
}
limits = {
memory = "256Mi"
}
}
}
}
}
}
lifecycle {
# KYVERNO_LIFECYCLE_V1: Kyverno admission webhook mutates dns_config with ndots=2
ignore_changes = [spec[0].template[0].spec[0].dns_config]
}
}
resource "kubernetes_service" "tuya-bridge" {
metadata {
name = "tuya-bridge"
namespace = kubernetes_namespace.tuya-bridge.metadata[0].name
labels = {
"app" = "tuya-bridge"
}
}
spec {
selector = {
app = "tuya-bridge"
}
port {
name = "http"
port = "80"
target_port = "8080"
}
}
}
module "ingress" {
source = "../../modules/kubernetes/ingress_factory"
# Smart-home automation HTTP API — Home Assistant and other automations
# call this with SERVICE_API_KEY in headers. Programmatic clients can't
# follow Authentik 302s.
# auth = "none": Smart-home automation API — SERVICE_API_KEY in headers; programmatic clients cannot follow Authentik redirects.
auth = "none"
dns_type = "proxied"
namespace = kubernetes_namespace.tuya-bridge.metadata[0].name
name = "tuya-bridge"
tls_secret_name = var.tls_secret_name
extra_annotations = {
"gethomepage.dev/enabled" = "true"
"gethomepage.dev/name" = "Tuya Bridge"
"gethomepage.dev/description" = "Smart device bridge"
"gethomepage.dev/icon" = "mdi-home-automation"
"gethomepage.dev/group" = "Smart Home"
"gethomepage.dev/pod-selector" = ""
}
}