-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.tf
executable file
·27 lines (24 loc) · 947 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
data "archive_file" "create_dist_pkg" {
type = "zip"
source_dir = "${path.module}/lambda_function"
output_path = "${path.module}/lambda_function.zip"
}
resource "aws_lambda_function" "export_pi_metrics" {
function_name = "export-pi-metrics-${var.env}"
role = aws_iam_role.export_pi_metrics_role.arn
handler = "export_pi.lambda_handler"
filename = data.archive_file.create_dist_pkg.output_path
runtime = "python3.9"
timeout = 60
tags = { Environment = var.env }
}
resource "aws_lambda_permission" "export_pi_metrics_invoke" {
statement_id = "AllowExecutionFromCloudWatchStart"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.export_pi_metrics.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.export_pi_metrics_start.arn
}
output "arn" {
value = aws_lambda_function.export_pi_metrics.arn
}