diff --git a/ingestion.tf b/ingestion.tf index 3acf7d9..fe7796c 100644 --- a/ingestion.tf +++ b/ingestion.tf @@ -115,4 +115,30 @@ resource "aws_sns_topic" "sonde_telem" { } } EOF +} + + +// SNS to MQTT + +resource "aws_lambda_function" "sns_to_mqtt" { + function_name = "sns-to-mqtt" + handler = "lambda_function.lambda_handler" + filename = "${path.module}/sns-to-mqtt/Archive.zip" # this should get replaced out when we make a proper build chain + publish = true + memory_size = 128 + role = aws_iam_role.basic_lambda_role.arn + runtime = "python3.9" + timeout = 3 + architectures = ["arm64"] + lifecycle { + ignore_changes = [environment] + } + +} + +resource "aws_lambda_permission" "sns_to_mqtt" { + action = "lambda:InvokeFunction" + function_name = aws_lambda_function.station.arn + principal = "apigateway.amazonaws.com" + source_arn = aws_sns_topic.sonde_telem.arn } \ No newline at end of file