Terraform - Lambda - agent ec2 stop 추가
This commit is contained in:
18
terraform/lambda/dsk-agent-ec2/events.tf
Normal file
18
terraform/lambda/dsk-agent-ec2/events.tf
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user