add tuya bridge module to toggle the ATS device via web [ci skip]

This commit is contained in:
Viktor Barzin 2025-10-24 14:00:06 +00:00
parent cc1951c828
commit 5e16a8152a
3 changed files with 112 additions and 0 deletions

View file

@ -121,6 +121,9 @@ variable "onlyoffice_jwt_token" { type = string }
variable "xray_reality_clients" { type = list(map(string)) }
variable "xray_reality_private_key" { type = string }
variable "xray_reality_short_ids" { type = list(string) }
variable "tiny_tuya_api_key" { type = string }
variable "tiny_tuya_api_secret" { type = string }
variable "tiny_tuya_service_secret" { type = string }
provider "kubernetes" {
@ -506,6 +509,10 @@ module "kubernetes_cluster" {
xray_reality_clients = var.xray_reality_clients
xray_reality_private_key = var.xray_reality_private_key
xray_reality_short_ids = var.xray_reality_short_ids
tiny_tuya_api_key = var.tiny_tuya_api_key
tiny_tuya_api_secret = var.tiny_tuya_api_secret
tiny_tuya_service_secret = var.tiny_tuya_service_secret
}

View file

@ -100,6 +100,9 @@ variable "onlyoffice_jwt_token" { type = string }
variable "xray_reality_clients" { type = list(map(string)) }
variable "xray_reality_private_key" { type = string }
variable "xray_reality_short_ids" { type = list(string) }
variable "tiny_tuya_api_key" { type = string }
variable "tiny_tuya_api_secret" { type = string }
variable "tiny_tuya_service_secret" { type = string }
@ -697,3 +700,12 @@ module "networking-toolbox" {
source = "./networking-toolbox"
tls_secret_name = var.tls_secret_name
}
module "tuya-bridge" {
source = "./tuya-bridge"
tls_secret_name = var.tls_secret_name
tiny_tuya_api_key = var.tiny_tuya_api_key
tiny_tuya_api_secret = var.tiny_tuya_api_secret
tiny_tuya_service_secret = var.tiny_tuya_service_secret
}

View file

@ -0,0 +1,93 @@
variable "tls_secret_name" {}
variable "tiny_tuya_api_key" { type = string }
variable "tiny_tuya_api_secret" { type = string }
variable "tiny_tuya_service_secret" { type = string }
resource "kubernetes_namespace" "tuya-bridge" {
metadata {
name = "tuya-bridge"
labels = {
"istio-injection" : "disabled"
}
}
}
module "tls_secret" {
source = "../setup_tls_secret"
namespace = "tuya-bridge"
tls_secret_name = var.tls_secret_name
}
resource "kubernetes_deployment" "tuya-bridge" {
metadata {
name = "tuya-bridge"
namespace = "tuya-bridge"
labels = {
app = "tuya-bridge"
}
}
spec {
replicas = 3
selector {
match_labels = {
app = "tuya-bridge"
}
}
template {
metadata {
labels = {
app = "tuya-bridge"
}
}
spec {
container {
image = "viktorbarzin/tuya_bridge"
name = "tuya-bridge"
port {
container_port = 8080
}
env {
name = "TINYTUYA_API_KEY"
value = var.tiny_tuya_api_key
}
env {
name = "TINYTUYA_API_SECRET"
value = var.tiny_tuya_api_secret
}
env {
name = "SERVICE_API_KEY" # used for auth the API endpoint
value = var.tiny_tuya_service_secret
}
}
}
}
}
}
resource "kubernetes_service" "tuya-bridge" {
metadata {
name = "tuya-bridge"
namespace = "tuya-bridge"
labels = {
"app" = "tuya-bridge"
}
}
spec {
selector = {
app = "tuya-bridge"
}
port {
name = "http"
port = "80"
target_port = "8080"
}
}
}
module "ingress" {
source = "../ingress_factory"
namespace = "tuya-bridge"
name = "tuya-bridge"
tls_secret_name = var.tls_secret_name
}