-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.tf
31 lines (26 loc) · 837 Bytes
/
lambda.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
data "archive_file" "lambda_zip" {
type = "zip"
source_dir = "${path.module}/src"
output_path = "${path.module}/lambda.zip"
}
resource "aws_lambda_function" "dns_helper" {
filename = "${path.module}/lambda.zip"
function_name = var.dns_helper
role = aws_iam_role.dns_helper.arn
handler = "main.handler"
timeout = var.timeout
runtime = "python3.7"
environment {
variables = var.variables
}
tags = {
CodeSHA = data.archive_file.lambda_zip.output_base64sha256
}
}
resource "aws_lambda_permission" "allow_cloudwatch" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.dns_helper.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.this.arn
}