-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathcloudwatch.tf
25 lines (22 loc) · 827 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
24
25
resource "aws_cloudwatch_event_rule" "this" {
name = "trigger-lambda-scheduler-${var.name}"
description = "Trigger lambda scheduler"
schedule_expression = var.cloudwatch_schedule_expression
tags = var.tags
}
resource "aws_cloudwatch_event_target" "this" {
arn = aws_lambda_function.this.arn
rule = aws_cloudwatch_event_rule.this.name
}
resource "aws_lambda_permission" "this" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
principal = "events.amazonaws.com"
function_name = aws_lambda_function.this.function_name
source_arn = aws_cloudwatch_event_rule.this.arn
}
resource "aws_cloudwatch_log_group" "this" {
name = "/aws/lambda/${var.name}"
retention_in_days = 14
tags = var.tags
}