# 2026-03-07 # main.tf — e2e тест: hello-world функция на Node.js 20. # # Использование: # 1. terraform init && terraform apply # 2. После apply (~2 мин kaniko): # curl -s -X POST -H 'Content-Type: application/json' -d '{"name":"Naeel"}' # Ожидаемый ответ: {"message":"Hello, Naeel! (nodejs20)"} # # Zip собирается автоматически из handler.js через hashicorp/archive. # Пересборка при изменении handler.js: просто terraform apply. terraform { required_providers { sless = { source = "terra.k8c.ru/naeel/sless" version = "~> 0.1.1" } archive = { source = "hashicorp/archive" version = "~> 2.0" } } } provider "sless" { endpoint = "https://sless-api.kube5s.ru" token = "dev-token-change-me" } # Автоматически собирает handler.zip из handler.js при каждом изменении файла data "archive_file" "handler" { type = "zip" source_file = "${path.module}/handler.js" output_path = "${path.module}/handler.zip" } resource "sless_function" "hello_node" { namespace = "default" name = "hello-node" 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 } resource "sless_trigger" "hello_node_http" { namespace = "default" name = "hello-node-http" type = "http" function = sless_function.hello_node.name } output "trigger_url" { value = sless_trigger.hello_node_http.url }