- 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
36 lines
1009 B
HCL
36 lines
1009 B
HCL
# 2025-06-05
|
|
# notes.tf — CRUD функция для таблицы notes.
|
|
# Роутинг по sub-path URL:
|
|
# POST /fn/default/notes/add?title=...&body=... → INSERT записи
|
|
# POST /fn/default/notes/update?id=1&title=...&body=... → UPDATE записи
|
|
# POST /fn/default/notes/delete?id=1 → DELETE записи
|
|
|
|
data "archive_file" "notes" {
|
|
type = "zip"
|
|
source_dir = "${path.module}/code/notes"
|
|
output_path = "${path.module}/dist/notes.zip"
|
|
}
|
|
|
|
resource "sless_function" "notes" {
|
|
namespace = "default"
|
|
name = "notes"
|
|
runtime = "python3.11"
|
|
entrypoint = "handler.handle"
|
|
memory_mb = 128
|
|
timeout_sec = 30
|
|
|
|
env_vars = {
|
|
PG_DSN = var.pg_dsn
|
|
}
|
|
|
|
code_path = data.archive_file.notes.output_path
|
|
code_hash = filesha256("${path.module}/code/notes/handler.py")
|
|
}
|
|
|
|
resource "sless_trigger" "notes_http" {
|
|
namespace = "default"
|
|
name = "notes-http"
|
|
type = "http"
|
|
function = sless_function.notes.name
|
|
}
|