Skip to content

Commit

Permalink
#10 enable scheduled trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
kunduso committed Jun 11, 2024
1 parent 4ea3dcf commit 7e298cd
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ resource "aws_lambda_function" "lambda_run" {
runtime = "python3.8"
}

# resource "aws_cloudwatch_event_rule" "lambda_trigger" {
# name = "lambda_trigger_rule"
# schedule_expression = "rate(10 minutes)"
# }
resource "aws_cloudwatch_event_rule" "lambda_trigger" {
name = "lambda_trigger_rule"
schedule_expression = "rate(10 minutes)"
}

# resource "aws_cloudwatch_event_target" "lambda_target" {
# rule = aws_cloudwatch_event_rule.lambda_trigger.name
# target_id = "lambda_target"
# arn = aws_lambda_function.lambda_run.arn
# }
resource "aws_cloudwatch_event_target" "lambda_target" {
rule = aws_cloudwatch_event_rule.lambda_trigger.name
target_id = "lambda_target"
arn = aws_lambda_function.lambda_run.arn
}

# resource "aws_lambda_permission" "allow_cloudwatch" {
# statement_id = "AllowExecutionFromCloudWatch"
# action = "lambda:InvokeFunction"
# function_name = aws_lambda_function.lambda_run.function_name
# principal = "events.amazonaws.com"
# source_arn = aws_cloudwatch_event_rule.lambda_trigger.arn
# }
resource "aws_lambda_permission" "allow_cloudwatch" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.lambda_run.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.lambda_trigger.arn
}

0 comments on commit 7e298cd

Please sign in to comment.