Files
dsk-iac/terraform/lambda/dsk-agent-ec2/events.tf
2024-01-29 14:20:01 +09:00

19 lines
684 B
HCL

resource "aws_cloudwatch_event_rule" "stop_lambda" {
name = var.stop_lambda_function_name
description = "Schedule for Stop Lambda Function"
schedule_expression = var.stop_lambda_schedule
}
resource "aws_cloudwatch_event_target" "stop_lambda" {
rule = aws_cloudwatch_event_rule.stop_lambda.name
target_id = var.stop_lambda_function_name
arn = aws_lambda_function.stop_lambda_function.arn
}
resource "aws_lambda_permission" "allow_cloudwatch_stop_lambda" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.stop_lambda_function.function_name
principal = "events.amazonaws.com"
}