-
Notifications
You must be signed in to change notification settings - Fork 4
/
ham_query.tf
196 lines (173 loc) · 6.67 KB
/
ham_query.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
resource "aws_lambda_function" "ham_get" {
function_name = "ham_get"
handler = "query_ham.get"
s3_bucket = aws_s3_bucket_object.lambda.bucket
s3_key = aws_s3_bucket_object.lambda.key
source_code_hash = data.archive_file.lambda.output_base64sha256
publish = true
memory_size = 256
role = aws_iam_role.basic_lambda_role.arn
runtime = "python3.9"
timeout = 30
architectures = ["arm64"]
environment {
variables = {
"ES" = "es.${local.domain_name}"
}
}
tags = {
Name = "ham_get"
}
}
resource "aws_lambda_function" "ham_telem" {
function_name = "ham_get_telem"
handler = "query_ham.get_telem"
s3_bucket = aws_s3_bucket_object.lambda.bucket
s3_key = aws_s3_bucket_object.lambda.key
reserved_concurrent_executions = 10
source_code_hash = data.archive_file.lambda.output_base64sha256
publish = true
memory_size = 1024
role = aws_iam_role.basic_lambda_role.arn
runtime = "python3.9"
timeout = 30
architectures = ["arm64"]
environment {
variables = {
"ES" = "es.${local.domain_name}"
}
}
tags = {
Name = "ham_get_telem"
}
}
resource "aws_lambda_function" "ham_telem_full" {
function_name = "ham_get_telem_full"
handler = "query_ham.get_telem_full"
s3_bucket = aws_s3_bucket_object.lambda.bucket
s3_key = aws_s3_bucket_object.lambda.key
source_code_hash = data.archive_file.lambda.output_base64sha256
publish = true
memory_size = 1024
role = aws_iam_role.basic_lambda_role.arn
runtime = "python3.9"
timeout = 30
architectures = ["arm64"]
environment {
variables = {
"ES" = "es.${local.domain_name}"
}
}
tags = {
Name = "ham_get_telem_full"
}
}
resource "aws_lambda_permission" "ham_get" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_get.arn
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:us-east-1:${data.aws_caller_identity.current.account_id}:${aws_apigatewayv2_api.main.id}/*/*/amateur"
}
resource "aws_lambda_permission" "ham_telem" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_telem.arn
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:us-east-1:${data.aws_caller_identity.current.account_id}:${aws_apigatewayv2_api.main.id}/*/*/amateur/telemetry"
}
resource "aws_lambda_permission" "ham_telem_full" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_telem_full.arn
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:us-east-1:${data.aws_caller_identity.current.account_id}:${aws_apigatewayv2_api.main.id}/*/*/amateur/telemetry/*"
}
resource "aws_apigatewayv2_route" "ham_get" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "GET /amateur"
target = "integrations/${aws_apigatewayv2_integration.ham_get.id}"
}
resource "aws_apigatewayv2_route" "ham_telem" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "GET /amateur/telemetry"
target = "integrations/${aws_apigatewayv2_integration.ham_telem.id}"
}
resource "aws_apigatewayv2_route" "ham_telem_full" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "GET /amateur/telemetry/{payload_callsign}"
target = "integrations/${aws_apigatewayv2_integration.ham_telem_full.id}"
}
resource "aws_apigatewayv2_integration" "ham_get" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_get.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}
resource "aws_apigatewayv2_integration" "ham_telem" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_telem.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}
resource "aws_apigatewayv2_integration" "ham_telem_full" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_telem_full.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}
resource "aws_lambda_function" "ham_get_listener_telemetry" {
function_name = "ham_get_listener_telemetry"
handler = "query_ham.get_listener_telemetry"
s3_bucket = aws_s3_bucket_object.lambda.bucket
s3_key = aws_s3_bucket_object.lambda.key
source_code_hash = data.archive_file.lambda.output_base64sha256
publish = true
memory_size = 256
role = aws_iam_role.basic_lambda_role.arn
runtime = "python3.9"
timeout = 30
architectures = ["arm64"]
environment {
variables = {
"ES" = "es.${local.domain_name}"
}
}
tags = {
Name = "ham_get_listener_telemetry"
}
}
resource "aws_lambda_permission" "ham_get_listener_telemetry" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_get_listener_telemetry.arn
principal = "apigateway.amazonaws.com"
source_arn = "arn:aws:execute-api:us-east-1:${data.aws_caller_identity.current.account_id}:${aws_apigatewayv2_api.main.id}/*/*/amateur/listeners/telemetry"
}
resource "aws_apigatewayv2_route" "ham_get_listener_telemetry" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "GET /amateur/listeners/telemetry"
target = "integrations/${aws_apigatewayv2_integration.ham_get_listener_telemetry.id}"
}
resource "aws_apigatewayv2_integration" "ham_get_listener_telemetry" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_get_listener_telemetry.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}