forked from sogeti/HavingFunWithLambda_101
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda-function.tf
50 lines (42 loc) · 1.44 KB
/
lambda-function.tf
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
#tfsec:ignore:aws-lambda-enable-tracing
resource "aws_lambda_function" "buienradar" {
filename = "${path.module}/buienradar/buienradar-lambda.zip"
function_name = "${var.prefix}-lambda-function"
description = "${var.prefix}-lambda-function"
role = aws_iam_role.lambda_role.arn
handler = "buienradar-lambda.lambda_handler"
source_code_hash = filebase64sha256("${path.module}/buienradar/buienradar-lambda.zip")
#Configuration Lambda
runtime = "python3.9"
timeout = "20"
memory_size = "128"
reserved_concurrent_executions = "1"
#xray configuration
tracing_config {
mode = "Active"
}
#Environment Config
environment {
variables = {
TopicArn = aws_sns_topic.buienradar.arn
}
}
tags = {
Name = "${var.prefix}-lambda-function"
}
}
#tfsec:ignore:aws-cloudwatch-log-group-customer-key
resource "aws_cloudwatch_log_group" "buienradar" {
name = "/aws/lambda/${aws_lambda_function.buienradar.function_name}"
retention_in_days = 3
tags = {
Name = "${var.prefix}-lambda-function"
}
}
resource "aws_lambda_permission" "allow_cloudwatch" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.buienradar.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.buienradar.arn
}