examples: auto-zip via hashicorp/archive, remove manual zip step
This commit is contained in:
parent
96664148e0
commit
92a7171943
@ -6,6 +6,9 @@
|
||||
# 2. После apply (~2 мин kaniko):
|
||||
# curl -s -X POST <trigger_url> -H 'Content-Type: application/json' -d '{"name":"Naeel"}'
|
||||
# Ожидаемый ответ: {"message":"Hello, Naeel! (nodejs20)"}
|
||||
#
|
||||
# Zip собирается автоматически из handler.js через hashicorp/archive.
|
||||
# Пересборка при изменении handler.js: просто terraform apply.
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
@ -13,6 +16,10 @@ terraform {
|
||||
source = "terra.k8c.ru/naeel/sless"
|
||||
version = "~> 0.1.1"
|
||||
}
|
||||
archive = {
|
||||
source = "hashicorp/archive"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +28,13 @@ provider "sless" {
|
||||
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"
|
||||
@ -29,8 +43,8 @@ resource "sless_function" "hello_node" {
|
||||
memory_mb = 128
|
||||
timeout_sec = 30
|
||||
|
||||
code_path = "${path.module}/handler.zip"
|
||||
code_hash = filemd5("${path.module}/handler.zip")
|
||||
code_path = data.archive_file.handler.output_path
|
||||
code_hash = data.archive_file.handler.output_md5
|
||||
}
|
||||
|
||||
resource "sless_trigger" "hello_node_http" {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user