Skip to content

Commit

Permalink
Switch to docker-based lambda for submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGalewsky committed Oct 31, 2023
1 parent ab61166 commit fed214b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
13 changes: 3 additions & 10 deletions infra/mdf/container_lambdas.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,14 @@ resource "aws_lambda_function" "mdf-connect-containerized-submit" {
}
}

data "archive_file" "python_lambda_package" {
type = "zip"
source_file = "${path.module}/code/submissions.py"
output_path = "nametest.zip"
}

resource "aws_lambda_function" "mdf-connect-containerized-submissions" {
for_each = local.environments
function_name = "${local.namespace}-submissions-${each.key}"
description = "lambda function from terraform"

filename = "nametest.zip"
source_code_hash = data.archive_file.python_lambda_package.output_base64sha256
runtime = "python3.11"
handler = "submissions.lambda_handler"
image_uri = "${aws_ecr_repository.mdf-connect-lambda-repo["submissions"].repository_url}:${each.key}"
package_type = "Image"
architectures = ["x86_64"]

role = aws_iam_role.lambda_execution.arn
timeout = 30
Expand Down
4 changes: 2 additions & 2 deletions infra/mdf/http_api_resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ resource "aws_apigatewayv2_route" "submission_status" {
resource "aws_apigatewayv2_route" "submissions" {
for_each = local.environments
api_id = aws_apigatewayv2_api.http_api[each.key].id
route_key = "GET /submissions"
route_key = "POST /submissions"
authorizer_id = aws_apigatewayv2_authorizer.globus-auth[each.key].id
authorization_type = "CUSTOM"

Expand All @@ -40,7 +40,7 @@ resource "aws_apigatewayv2_route" "submissions" {
resource "aws_apigatewayv2_route" "user_submissions" {
for_each = local.environments
api_id = aws_apigatewayv2_api.http_api[each.key].id
route_key = "GET /submissions/{user_id}"
route_key = "POST /submissions/{user_id}"
authorizer_id = aws_apigatewayv2_authorizer.globus-auth[each.key].id
authorization_type = "CUSTOM"

Expand Down
4 changes: 4 additions & 0 deletions infra/mdf/http_api_stages.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ resource "aws_apigatewayv2_stage" "test" {
destination_arn = "${aws_cloudwatch_log_group.MDFConnect-logs.arn}"
format = "$context.extendedRequestId $context.identity.sourceIp $context.identity.caller $context.identity.user [$context.requestTime] $context.httpMethod $context.resourcePath $context.protocol $context.status $context.responseLength $context.requestId $context.extendedRequestId"
}
default_route_settings{
throttling_burst_limit = 5000
throttling_rate_limit = 10000
}
}# Output the URLs for each environment
output "auth_url" {
value = "${aws_apigatewayv2_stage.prod.invoke_url}/auth"
Expand Down
2 changes: 1 addition & 1 deletion infra/mdf/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ locals {
GitHubRepo = "connect_server"
envs = ["test", "prod"]
environments = toset(local.envs)
funcs = ["auth", "submit", "status"]
funcs = ["auth", "submit", "status", "submissions"]
functions = toset(local.funcs)
account_id = data.aws_caller_identity.current.account_id
region = "us-east-1"
Expand Down

0 comments on commit fed214b

Please sign in to comment.