-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction.tf
More file actions
52 lines (41 loc) · 1.23 KB
/
function.tf
File metadata and controls
52 lines (41 loc) · 1.23 KB
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
locals {
lambda_layers = concat(
["arn:aws:lambda:${var.region}:017000801446:layer:AWSLambdaPowertoolsPythonV3-python312-x86_64:15"],
var.enable_lambda_insights ?
["arn:aws:lambda:${var.region}:580247275435:layer:LambdaInsightsExtension:${var.lambda_insights_layer_version}"]
: []
)
environment = merge(
var.environment,
{
QUEUE_URL = var.queue_url
SCRAPE_CONFIG = var.scrape_config
}
)
}
data "archive_file" "this" {
type = "zip"
source_dir = "${path.module}/src"
output_path = "${path.module}/${var.name}.zip"
excludes = ["**/__pycache__/*"]
}
# tfsec:ignore:aws-lambda-enable-tracing
resource "aws_lambda_function" "this" {
filename = data.archive_file.this.output_path
function_name = var.name
role = aws_iam_role.this.arn
handler = "function.handler"
runtime = "python3.12"
source_code_hash = data.archive_file.this.output_base64sha256
reserved_concurrent_executions = var.max_concurrency
layers = local.lambda_layers
timeout = var.timeout
memory_size = var.memory_size
environment {
variables = local.environment
}
depends_on = [
aws_cloudwatch_log_group.this,
data.archive_file.this
]
}