sless-primer/hello-node/job.tf
“Naeel” b73591131a fix: откат 409-fallback из клиента провайдера (provider v0.1.6 не опубликован с изменениями)
- terraform/provider/internal/client/client.go: откат 409 fallback для
  CreateFunction, CreateTrigger, CreateJob — import не нужен в данном провайдере,
  409 должен быть ошибкой
- examples/hello-node/main.tf: версия провайдера ~> 0.1.6 (опубликована
  без изменений клиента — только исходная версия кода)
- examples/hello-node/job.tf: run_id=9, numbers=[100,200,300]

Тесты пройдены: plan(no-changes), state-rm+apply, code update, run_id++, destroy+apply
2026-03-09 08:17:17 +04:00

53 lines
1.7 KiB
HCL
Raw 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-08
# job.tf — одноразовая функция: суммирует числа из переданного массива.
# Код: code/handler-job.js
#
# Использование:
# terraform apply
# # apply блокируется до завершения джоба (~2 мин kaniko + выполнение)
# terraform output job_message
#
# Повторный запуск — изменить event_json и снова terraform apply.
data "archive_file" "handler_job" {
type = "zip"
source_file = "${path.module}/code/handler-job.js"
output_path = "${path.module}/handler-job.zip"
}
resource "sless_function" "hello_job" {
namespace = "default"
name = "hello-job"
runtime = "nodejs20"
entrypoint = "handler-job.handle"
memory_mb = 128
timeout_sec = 30
code_path = data.archive_file.handler_job.output_path
# filesha256 исходного файла — надёжнее чем output_md5 zip
code_hash = filesha256("${path.module}/code/handler-job.js")
}
# Одноразовый запуск. Все поля immutable — изменение любого пересоздаёт джоб.
# run_id: 0 = не запускать, 1+ = запустить. Для повторного запуска увеличь run_id (1→2→3...).
resource "sless_job" "hello_run" {
namespace = "default"
name = "hello-run"
function = sless_function.hello_job.name
event_json = jsonencode({ numbers = [100, 200, 300] })
wait_timeout_sec = 600
run_id = 9
}
output "job_phase" {
value = sless_job.hello_run.phase
}
output "job_message" {
value = sless_job.hello_run.message
}
output "job_completion_time" {
value = sless_job.hello_run.completion_time
}