sless-primer/notes-python/sql-runner.tf
“Naeel” daf750e89d feat: notes-python CRUD example + runtime path/query forwarding
- 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
2026-03-09 09:51:56 +04:00

27 lines
919 B
HCL

# 2025-06-05
# sql-runner.tf — универсальная функция для выполнения SQL запросов.
# Используется джобами для DDL операций (CREATE TABLE, индексы, миграции).
# event.statements — массив SQL строк, выполняются последовательно в одной транзакции.
data "archive_file" "sql_runner" {
type = "zip"
source_dir = "${path.module}/code/sql-runner"
output_path = "${path.module}/dist/sql-runner.zip"
}
resource "sless_function" "sql_runner" {
namespace = "default"
name = "sql-runner"
runtime = "python3.11"
entrypoint = "handler.handle"
memory_mb = 128
timeout_sec = 30
env_vars = {
PG_DSN = var.pg_dsn
}
code_path = data.archive_file.sql_runner.output_path
code_hash = filesha256("${path.module}/code/sql-runner/handler.py")
}