@cloudnux/cli 0.12.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.deploy/aws/scheduler/main.tf +1 -1
- package/.deploy/aws/scheduler/variables.tf +2 -2
- package/.deploy/aws/websocket/main.tf +49 -0
- package/.deploy/aws/websocket/variables.tf +22 -0
- package/dist/cli.mjs +2841 -370
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +2950 -0
- package/dist/schema/entrypoint.schema.json +16 -3
- package/dist/templates/cloud/entrypoint-build.ts.ejs +4 -18
- package/dist/templates/cloud/entrypoint-triggers.tf.ejs +98 -51
- package/dist/templates/local/dev-server.ts.ejs +8 -4
- package/dist/templates/local/module.ts.ejs +4 -3
- package/dist/types.d.ts +10 -11
- package/package.json +12 -11
- package/dist/templates/cloud/WIP.ts.ejs +0 -564
- package/dist/templates/local/triggers/event.ts.ejs +0 -7
- package/dist/templates/local/triggers/http.ts.ejs +0 -11
- package/dist/templates/local/triggers/schedule.ts.ejs +0 -7
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
locals {
|
|
2
|
+
# Map event names to their standard WebSocket route keys
|
|
3
|
+
event_to_route_key = {
|
|
4
|
+
connect = "$connect"
|
|
5
|
+
disconnect = "$disconnect"
|
|
6
|
+
message = "$default"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
# Resolve each route's route_key: explicit override > event-based default
|
|
10
|
+
resolved_routes = {
|
|
11
|
+
for k, v in var.routes : k => merge(v, {
|
|
12
|
+
resolved_key = coalesce(try(v.route_key, null), lookup(local.event_to_route_key, v.event, "$default"))
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
data "aws_apigatewayv2_api" "this" {
|
|
18
|
+
api_id = var.api_gateway_id
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
resource "aws_apigatewayv2_integration" "this" {
|
|
22
|
+
for_each = var.routes
|
|
23
|
+
|
|
24
|
+
api_id = var.api_gateway_id
|
|
25
|
+
integration_type = "AWS_PROXY"
|
|
26
|
+
integration_uri = var.lambda_arn
|
|
27
|
+
content_handling_strategy = "CONVERT_TO_TEXT"
|
|
28
|
+
|
|
29
|
+
lifecycle {
|
|
30
|
+
create_before_destroy = true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_apigatewayv2_route" "this" {
|
|
35
|
+
for_each = local.resolved_routes
|
|
36
|
+
|
|
37
|
+
api_id = var.api_gateway_id
|
|
38
|
+
route_key = each.value.resolved_key
|
|
39
|
+
target = "integrations/${aws_apigatewayv2_integration.this[each.key].id}"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# # Grant Lambda permission to be invoked by this WebSocket API Gateway
|
|
43
|
+
# resource "aws_lambda_permission" "this" {
|
|
44
|
+
# statement_id = "AllowWebSocketAPIGateway-${var.lambda_name}"
|
|
45
|
+
# action = "lambda:InvokeFunction"
|
|
46
|
+
# function_name = var.lambda_name
|
|
47
|
+
# principal = "apigateway.amazonaws.com"
|
|
48
|
+
# source_arn = "${data.aws_apigatewayv2_api.this.execution_arn}/*/*"
|
|
49
|
+
# }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
variable "api_gateway_id" {
|
|
2
|
+
description = "ID of the existing WebSocket API Gateway V2 to attach routes to."
|
|
3
|
+
type = string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
variable "lambda_name" {
|
|
7
|
+
description = "Name of the Lambda function."
|
|
8
|
+
type = string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
variable "lambda_arn" {
|
|
12
|
+
description = "ARN of the Lambda function."
|
|
13
|
+
type = string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variable "routes" {
|
|
17
|
+
description = "Map of WebSocket route definitions keyed by entry name."
|
|
18
|
+
type = map(object({
|
|
19
|
+
event = string # connect | disconnect | message
|
|
20
|
+
route_key = optional(string) # overrides the default $connect/$disconnect/$default mapping
|
|
21
|
+
}))
|
|
22
|
+
}
|