-
Notifications
You must be signed in to change notification settings - Fork 4
/
ham_flightdoc.tf
90 lines (81 loc) · 3.23 KB
/
ham_flightdoc.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
# cognito auth role
resource "aws_lambda_function" "ham_flight_doc" {
function_name = "ham-put-flight-doc"
handler = "ham_update_flight_doc.lambda_handler"
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 = {
"ES" = "es.${local.domain_name}"
}
}
}
resource "aws_lambda_permission" "ham_flight_doc" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_flight_doc.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/flightdoc"
}
resource "aws_apigatewayv2_route" "ham_flight_doc" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "AWS_IAM"
route_key = "PUT /amateur/flightdoc"
target = "integrations/${aws_apigatewayv2_integration.ham_flight_doc.id}"
}
resource "aws_apigatewayv2_integration" "ham_flight_doc" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_flight_doc.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}
resource "aws_lambda_function" "ham_flight_doc_get" {
function_name = "ham-get-flight-doc"
handler = "ham_update_flight_doc.query"
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 = {
"ES" = "es.${local.domain_name}"
}
}
}
resource "aws_lambda_permission" "ham_flight_doc_get" {
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.ham_flight_doc_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/flightdoc/*"
}
resource "aws_apigatewayv2_route" "ham_flight_doc_get" {
api_id = aws_apigatewayv2_api.main.id
api_key_required = false
authorization_type = "NONE"
route_key = "GET /amateur/flightdoc/{payload_callsign}"
target = "integrations/${aws_apigatewayv2_integration.ham_flight_doc_get.id}"
}
resource "aws_apigatewayv2_integration" "ham_flight_doc_get" {
api_id = aws_apigatewayv2_api.main.id
connection_type = "INTERNET"
integration_method = "POST"
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.ham_flight_doc_get.arn
timeout_milliseconds = 30000
payload_format_version = "2.0"
}