-
Notifications
You must be signed in to change notification settings - Fork 14
/
cloudwatch.tf
23 lines (20 loc) · 881 Bytes
/
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
resource "aws_cloudwatch_event_rule" "schedule" {
name = "${var.prefix}es-cleanup-execution-schedule${var.suffix}"
description = "${var.prefix}es-cleanup execution schedule${var.suffix}"
schedule_expression = var.schedule
}
resource "aws_cloudwatch_event_target" "es_cleanup" {
target_id = "${var.prefix}lambda-es-cleanup${var.suffix}"
rule = aws_cloudwatch_event_rule.schedule.name
arn = aws_lambda_function.es_cleanup.arn
}
resource "aws_lambda_permission" "allow_cloudwatch" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.es_cleanup.arn
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.schedule.arn
}
resource "aws_cloudwatch_log_group" "cwlog" {
name = "/aws/lambda/${var.prefix}es-cleanup${var.suffix}"
}