sless-examples/simple-node/time-display.tf
2026-03-09 17:57:29 +04:00

29 lines
1.3 KiB
HCL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Создано: 2026-03-09 / Изменено: 2026-03-09
# time-display.tf — HTTP-функция, доступная по URL после apply.
# Получает результат джоба (из time-getter.tf) через переменную окружения JOB_TIME.
# HTTP-функция — отвечает на запросы по URL из outputs.tf
resource "sless_function" "time_display" {
name = "simple-node-time-display" # уникальное имя в namespace
runtime = "nodejs20"
entrypoint = "time_display.showTime" # файл.функция в code/time_display/
memory_mb = 64
# Передаём результат джоба в функцию через переменную окружения.
# В коде функции: process.env.JOB_TIME
env_vars = {
JOB_TIME = sless_job.run_getter.message
}
source_dir = "${path.module}/code/time_display"
depends_on = [sless_job.run_getter] # ждём завершения джоба перед деплоем функции
}
# Публикуем функцию по HTTP — URL будет в outputs.tf
resource "sless_trigger" "display_http" {
name = "simple-node-display-http"
type = "http"
function = sless_function.time_display.name
}