43 lines
1.3 KiB
Terraform
43 lines
1.3 KiB
Terraform
# 2026-03-08
|
|
# job.tf — вариант с одноразовым запуском: terraform apply выполняет функцию и ждёт результата.
|
|
#
|
|
# Использование:
|
|
# terraform apply
|
|
# # apply блокируется до завершения джоба (~2 мин kaniko + выполнение)
|
|
# terraform output job_message
|
|
#
|
|
# Повторный запуск — изменить event_json и снова terraform apply.
|
|
|
|
resource "sless_function" "hello_job" {
|
|
namespace = "default"
|
|
name = "hello-job"
|
|
runtime = "nodejs20"
|
|
entrypoint = "handler.handle"
|
|
memory_mb = 128
|
|
timeout_sec = 30
|
|
|
|
code_path = data.archive_file.handler.output_path
|
|
code_hash = data.archive_file.handler.output_md5
|
|
}
|
|
|
|
# Одноразовый запуск. Все поля immutable — изменение любого пересоздаёт джоб.
|
|
resource "sless_job" "hello_run" {
|
|
namespace = "default"
|
|
name = "hello-run"
|
|
function = sless_function.hello_job.name
|
|
event_json = jsonencode({ name = "Naeel" })
|
|
wait_timeout_sec = 120
|
|
}
|
|
|
|
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
|
|
}
|