switch to s3 for lambda deployments

This commit is contained in:
Michaela Wheeler 2021-12-20 19:30:23 +11:00
parent ae77f0e933
commit a82a895f26
8 changed files with 46 additions and 18 deletions

View File

@ -65,7 +65,8 @@ EOF
resource "aws_lambda_function" "historic_to_s3" {
function_name = "historic_to_s3"
handler = "historic_es_to_s3.handler"
filename = data.archive_file.lambda.output_path
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 = 3096
@ -82,7 +83,8 @@ resource "aws_lambda_function" "historic_to_s3" {
resource "aws_lambda_function" "queue_data_update" {
function_name = "queue_data_update"
handler = "queue_data_update.handler"
filename = data.archive_file.lambda.output_path
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
@ -210,7 +212,8 @@ EOF
resource "aws_lambda_function" "history" {
function_name = "history"
handler = "history.history"
filename = data.archive_file.lambda.output_path
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 = 512

View File

@ -1,7 +1,8 @@
resource "aws_lambda_function" "upload_telem" {
function_name = "sonde-api-to-iot-core"
handler = "sonde_api_to_iot_core.lambda_handler"
filename = data.archive_file.lambda.output_path
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
@ -19,7 +20,8 @@ resource "aws_lambda_function" "upload_telem" {
resource "aws_lambda_function" "station" {
function_name = "station-api-to-iot-core"
handler = "station_api_to_iot_core.lambda_handler"
filename = data.archive_file.lambda.output_path
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

10
main.tf
View File

@ -129,4 +129,14 @@ data "archive_file" "lambda" {
type = "zip"
source_dir = "lambda/"
output_path = "${path.module}/build/lambda.zip"
}
resource "aws_s3_bucket" "lambda_functions" {
}
resource "aws_s3_bucket_object" "lambda" {
bucket = aws_s3_bucket.lambda_functions.bucket
key = "lambda.zip"
source = data.archive_file.lambda.output_path
etag = data.archive_file.lambda.output_md5
}

View File

@ -63,7 +63,8 @@ EOF
resource "aws_lambda_function" "predict_updater" {
function_name = "predict_updater"
handler = "predict_updater.predict"
filename = data.archive_file.lambda.output_path
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
@ -139,7 +140,8 @@ resource "aws_apigatewayv2_integration" "reverse_predictions" {
resource "aws_lambda_function" "predictions" {
function_name = "predictions"
handler = "predict.predict"
filename = data.archive_file.lambda.output_path
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
@ -164,7 +166,8 @@ resource "aws_lambda_permission" "predictions" {
resource "aws_lambda_function" "reverse_predictions" {
function_name = "reverse-predictions"
handler = "reverse_predict.predict"
filename = data.archive_file.lambda.output_path
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
@ -659,7 +662,8 @@ EOF
resource "aws_lambda_function" "predictor_update_trigger_lambda" {
function_name = "tawhiri-updater"
handler = "tawhiri_updater.handler"
filename = data.archive_file.lambda.output_path
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

View File

@ -2,7 +2,8 @@
resource "aws_lambda_function" "get_sondes" {
function_name = "query"
handler = "query.get_sondes"
filename = data.archive_file.lambda.output_path
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
@ -25,7 +26,8 @@ resource "aws_lambda_function" "get_sondes" {
resource "aws_lambda_function" "get_telem" {
function_name = "get_telem"
handler = "query.get_telem"
filename = data.archive_file.lambda.output_path
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
@ -43,7 +45,8 @@ resource "aws_lambda_function" "get_telem" {
resource "aws_lambda_function" "get_sites" {
function_name = "get_sites"
handler = "query.get_sites"
filename = data.archive_file.lambda.output_path
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
@ -61,7 +64,8 @@ resource "aws_lambda_function" "get_sites" {
resource "aws_lambda_function" "get_listener_telemetry" {
function_name = "get_listener_telemetry"
handler = "query.get_listener_telemetry"
filename = data.archive_file.lambda.output_path
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

View File

@ -54,7 +54,8 @@ EOF
resource "aws_lambda_function" "recovered_get" {
function_name = "recovered_get"
handler = "recovered.get"
filename = data.archive_file.lambda.output_path
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
@ -73,7 +74,8 @@ resource "aws_lambda_function" "recovered_get" {
resource "aws_lambda_function" "recovered_stats" {
function_name = "recovered_stats"
handler = "recovered.stats"
filename = data.archive_file.lambda.output_path
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
@ -92,7 +94,8 @@ resource "aws_lambda_function" "recovered_stats" {
resource "aws_lambda_function" "recovered_put" {
function_name = "recovered_put"
handler = "recovered.put"
filename = data.archive_file.lambda.output_path
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

View File

@ -57,7 +57,8 @@ EOF
resource "aws_lambda_function" "sqs_to_elk" {
function_name = "sqs-to-elk"
handler = "sqs_to_elk.lambda_handler"
filename = data.archive_file.lambda.output_path
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

View File

@ -26,7 +26,8 @@ EOF
resource "aws_lambda_function" "sign_socket" {
function_name = "sign-websocket"
handler = "sign_websocket.lambda_handler"
filename = data.archive_file.lambda.output_path
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