-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudwatch.tf
29 lines (26 loc) · 1.14 KB
/
cloudwatch.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
resource "aws_cloudwatch_event_rule" "satori-lambda-pagerduty-eventrule" {
name = "${var.satori_prefix}_eventrule"
description = "Schedule satori lambda pagerduty function"
schedule_expression = "rate(${var.hours} hours)"
}
resource "aws_cloudwatch_event_target" "satori-lambda-pagerduty-eventtarget" {
target_id = "lambda-pagerduty-function-target"
rule = aws_cloudwatch_event_rule.satori-lambda-pagerduty-eventrule.name
arn = aws_lambda_function.satori_terraform_lambda_pagerduty.arn
input = <<JSON
{
"secret_name": "${var.satori_prefix}_secrets",
"aws_region": "${var.aws_region}",
"reporting_type": "${var.reporting_type}",
"hours": "${var.hours}",
"large_record_threshold": "${var.large_record_threshold}"
}
JSON
}
resource "aws_lambda_permission" "allow_cloudwatch" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.satori_terraform_lambda_pagerduty.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.satori-lambda-pagerduty-eventrule.arn
}