@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.
@@ -4,7 +4,7 @@ data "aws_iam_role" "eventbridge_role" {
4
4
 
5
5
  resource "aws_scheduler_schedule_group" "this" {
6
6
 
7
- name = var.component
7
+ name = var.module
8
8
 
9
9
  lifecycle {
10
10
  create_before_destroy = true
@@ -10,8 +10,8 @@ variable "schedules" {
10
10
  maximum_window_in_minutes = optional(number)
11
11
  }))
12
12
  }
13
- variable "component" {
14
- description = "The name of the component."
13
+ variable "module" {
14
+ description = "The name of the module."
15
15
  type = string
16
16
  }
17
17
 
@@ -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
+ }