-
Notifications
You must be signed in to change notification settings - Fork 4
/
ham_ttn_helium.tf
90 lines (80 loc) · 3.24 KB
/
ham_ttn_helium.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
resource "aws_lambda_function" "ham_helium_upload_telem" {
function_name = "ham-helium-put-api"
handler = "ttn_helium.lambda_handler_helium"
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 = 128
role = aws_iam_role.basic_lambda_role.arn
runtime = "python3.9"
timeout = 30
architectures = ["arm64"]
environment {
variables = {
"HAM_SNS_TOPIC" = aws_sns_topic.ham_telem.arn
}
}
}
resource "aws_lambda_permission" "ham_helium_upload_telem" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_helium_upload_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}/*/*/helium"
}
resource "aws_apigatewayv2_route" "ham_helium_upload_telem" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "POST /helium"
target = "integrations/${aws_apigatewayv2_integration.ham_helium_upload_telem.id}"
}
resource "aws_apigatewayv2_integration" "ham_helium_upload_telem" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_helium_upload_telem.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}
resource "aws_lambda_function" "ham_ttn_upload_telem" {
function_name = "ham-ttn-put-api"
handler = "ttn_helium.lambda_handler_ttn"
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 = 128
role = aws_iam_role.basic_lambda_role.arn
runtime = "python3.9"
timeout = 30
architectures = ["arm64"]
environment {
variables = {
"HAM_SNS_TOPIC" = aws_sns_topic.ham_telem.arn
}
}
}
resource "aws_lambda_permission" "ham_ttn_upload_telem" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_ttn_upload_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}/*/*/ttn"
}
resource "aws_apigatewayv2_route" "ham_ttn_upload_telem" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "POST /ttn"
target = "integrations/${aws_apigatewayv2_integration.ham_ttn_upload_telem.id}"
}
resource "aws_apigatewayv2_integration" "ham_ttn_upload_telem" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_ttn_upload_telem.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}