|
2 | 2 | # Lambda Functions |
3 | 3 | # ============================================================================= |
4 | 4 |
|
| 5 | +# ============================================================================= |
| 6 | +# boto3 Lambda Layer (Python 3.13 no longer bundles the AWS SDK) |
| 7 | +# ============================================================================= |
| 8 | + |
| 9 | +resource "null_resource" "boto3_layer" { |
| 10 | + triggers = { |
| 11 | + requirements = filesha256("${path.module}/boto3_layer_requirements.txt") |
| 12 | + } |
| 13 | + |
| 14 | + provisioner "local-exec" { |
| 15 | + command = <<-EOT |
| 16 | + rm -rf ${path.module}/.build/boto3_layer |
| 17 | + mkdir -p ${path.module}/.build/boto3_layer/python |
| 18 | + pip3 install \ |
| 19 | + -r ${path.module}/boto3_layer_requirements.txt \ |
| 20 | + -t ${path.module}/.build/boto3_layer/python \ |
| 21 | + --quiet |
| 22 | + EOT |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +data "archive_file" "boto3_layer" { |
| 27 | + type = "zip" |
| 28 | + source_dir = "${path.module}/.build/boto3_layer" |
| 29 | + output_path = "${path.module}/.build/boto3_layer.zip" |
| 30 | + depends_on = [null_resource.boto3_layer] |
| 31 | +} |
| 32 | + |
| 33 | +resource "aws_lambda_layer_version" "boto3" { |
| 34 | + filename = data.archive_file.boto3_layer.output_path |
| 35 | + layer_name = "${local.name_prefix}-boto3" |
| 36 | + source_code_hash = data.archive_file.boto3_layer.output_base64sha256 |
| 37 | + |
| 38 | + compatible_runtimes = ["python3.13"] |
| 39 | +} |
| 40 | + |
5 | 41 | # Package Lambda source code into zip archives |
6 | 42 | data "archive_file" "submit_build" { |
7 | 43 | type = "zip" |
@@ -35,6 +71,7 @@ resource "aws_lambda_function" "submit_build" { |
35 | 71 | timeout = 30 |
36 | 72 | memory_size = 128 |
37 | 73 | role = aws_iam_role.lambda_submit.arn |
| 74 | + layers = [aws_lambda_layer_version.boto3.arn] |
38 | 75 |
|
39 | 76 | environment { |
40 | 77 | variables = { |
@@ -68,6 +105,7 @@ resource "aws_lambda_function" "process_build" { |
68 | 105 | timeout = 60 |
69 | 106 | memory_size = 256 |
70 | 107 | role = aws_iam_role.lambda_process.arn |
| 108 | + layers = [aws_lambda_layer_version.boto3.arn] |
71 | 109 |
|
72 | 110 | environment { |
73 | 111 | variables = { |
@@ -121,6 +159,7 @@ resource "aws_lambda_function" "check_status" { |
121 | 159 | timeout = 15 |
122 | 160 | memory_size = 128 |
123 | 161 | role = aws_iam_role.lambda_status.arn |
| 162 | + layers = [aws_lambda_layer_version.boto3.arn] |
124 | 163 |
|
125 | 164 | environment { |
126 | 165 | variables = { |
|
0 commit comments