@@ -18,6 +18,7 @@ variable "http_api" {
18
18
enable_simple_responses = optional (bool )
19
19
})), {})
20
20
21
+ default_authorizer = optional (string )
21
22
})
22
23
description = " The custom configuration for the API Gateway. Most of it will be inferred from Lambda events."
23
24
default = null
@@ -27,8 +28,17 @@ locals {
27
28
http_api_name = try (coalesce (var. http_api . name , local. config . project_name ), null )
28
29
29
30
_http_api_definition_parsed = try (jsondecode (var. http_api . definition ), {})
31
+
32
+ _http_api_lambda_api_definition = {
33
+ for http_path , path_items in module . config_lambda . api_definition : http_path => {
34
+ for http_method , path_item in path_items : http_method => merge (path_item, {
35
+ authorizer = try (path_item. authorizer , var. http_api . default_authorizer , null )
36
+ })
37
+ }
38
+ }
39
+
30
40
http_api_definition = merge (local. _http_api_definition_parsed, {
31
- for http_path , path_items in module . config_lambda . api_definition : http_path => merge (try (local. _http_api_definition_parsed[http_path ], {}), {
41
+ for http_path , path_items in local . _http_api_lambda_api_definition : http_path => merge (try (local. _http_api_definition_parsed[http_path ], {}), {
32
42
for http_method , path_item in path_items : http_method => {
33
43
34
44
lambda = {
@@ -38,14 +48,15 @@ locals {
38
48
authorizer = try (path_item. authorizer , null ) == null ? null : {
39
49
name = try (var. http_api . authorizers [path_item . authorizer ]. name , path_item. authorizer )
40
50
lambda = {
41
- function_name = module.config_lambda.functions [var.http_api.authorizers[path_item.authorizer].function_id].function_name
51
+ function_name = module.config_lambda.lambda_definitions [var.http_api.authorizers[path_item.authorizer].function_id].function_name
42
52
}
43
53
header = try (var. http_api . authorizers [path_item . authorizer ]. header , null )
44
54
authorizerType = try (var. http_api . authorizers [path_item . authorizer ]. type , null )
45
55
identitySource = try (join (" ," , var. http_api . authorizers [path_item . authorizer ]. identity_source ), null )
46
56
resultTtlInSeconds = try (var. http_api . authorizers [path_item . authorizer ]. ttl_in_seconds , null )
47
57
}
48
58
59
+
49
60
}
50
61
})
51
62
})
@@ -57,8 +68,8 @@ module "http_api" {
57
68
58
69
name = local. http_api_name
59
70
60
- region = data . aws_region . current . name
61
- account_id = data . aws_caller_identity . current . account_id
71
+ region = var . starchart . aws_region
72
+ account_id = var . starchart . aws_account_id
62
73
definition = local. http_api_definition
63
74
64
75
disable_execute_api_endpoint = var. http_api . disable_execute_api_endpoint
0 commit comments