- invoke.go: forward sub-path and query string to function pods - server.js v0.1.2: add _path, _query, _method to event - server.py v0.1.1: add _path, _query, _method to event - upload.go: bump runtime versions (nodejs20:v0.1.2, python3.11:v0.1.1) - examples/notes-python: CRUD notes via sub-path routing - sql-runner: generic SQL executor for DDL jobs - notes: CRUD router (/add, /update, /delete) - notes-list: SELECT all notes - init.tf: create TABLE + INDEX on apply
35 lines
1.1 KiB
HCL
35 lines
1.1 KiB
HCL
# 2025-06-05
|
|
# init.tf — джобы инициализации БД: создание таблицы + индекса.
|
|
# Запускаются один раз при terraform apply.
|
|
# Для повторного запуска (например после drop) — увеличь run_id.
|
|
|
|
resource "sless_job" "create_table" {
|
|
namespace = "default"
|
|
name = "notes-create-table"
|
|
function = sless_function.sql_runner.name
|
|
wait_timeout_sec = 120
|
|
run_id = 1
|
|
|
|
event_json = jsonencode({
|
|
statements = [
|
|
"CREATE TABLE IF NOT EXISTS notes (id serial PRIMARY KEY, title text NOT NULL, body text, created_at timestamp DEFAULT now())"
|
|
]
|
|
})
|
|
}
|
|
|
|
resource "sless_job" "create_index" {
|
|
depends_on = [sless_job.create_table]
|
|
|
|
namespace = "default"
|
|
name = "notes-create-index"
|
|
function = sless_function.sql_runner.name
|
|
wait_timeout_sec = 60
|
|
run_id = 1
|
|
|
|
event_json = jsonencode({
|
|
statements = [
|
|
"CREATE INDEX IF NOT EXISTS notes_created_idx ON notes(created_at DESC)"
|
|
]
|
|
})
|
|
}
|