-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.tf
82 lines (69 loc) · 1.78 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
locals {
functions = {
"go" = {
path = "go"
runtime = "go120"
handler = "Handle"
}
"node" = {
path = "node"
runtime = "node20"
handler = "handler.handle"
}
"php" = {
path = "php"
runtime = "php82"
handler = "handler.handle"
}
"python" = {
path = "python"
runtime = "python311"
handler = "handler.handler"
}
"rust" = {
path = "rust"
runtime = "rust179"
handler = "handler"
}
}
subject_name = "triggers-nats-factorial"
}
resource "scaleway_function_namespace" "main" {
name = "triggers-getting-started"
}
data "archive_file" "function" {
for_each = local.functions
type = "zip"
source_dir = "${path.module}/${each.value.path}"
output_path = "${path.module}/${each.value.path}.zip"
}
resource "scaleway_function" "main" {
for_each = local.functions
namespace_id = scaleway_function_namespace.main.id
name = each.key
runtime = each.value.runtime
handler = each.value.handler
privacy = "public"
zip_file = data.archive_file.function[each.key].output_path
zip_hash = data.archive_file.function[each.key].output_sha256
deploy = true
memory_limit = 512 # MB / 280 mVCPU
min_scale = 0
}
resource "scaleway_function_trigger" "main_sqs" {
for_each = local.functions
function_id = scaleway_function.main[each.key].id
name = "sqs-on-factorial-request"
sqs {
queue = scaleway_mnq_sqs_queue.main[each.key].name
}
}
resource "scaleway_function_trigger" "main_nats" {
for_each = local.functions
function_id = scaleway_function.main[each.key].id
name = "nats-on-factorial-request"
nats {
account_id = scaleway_mnq_nats_account.main.id
subject = local.subject_name
}
}