Terraform - Lambda - agent ec2 stop 추가

This commit is contained in:
dsk-minchulahn
2024-01-29 14:20:01 +09:00
parent 61149888de
commit 3c9be964a5
9 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
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"
}