Skip to content

Instantly share code, notes, and snippets.

@nhammad
Created July 22, 2022 20:09
Show Gist options
  • Save nhammad/5d7dd3bcd939f64a6afa78e3894496d0 to your computer and use it in GitHub Desktop.
Save nhammad/5d7dd3bcd939f64a6afa78e3894496d0 to your computer and use it in GitHub Desktop.
resource "aws_cloudwatch_event_rule" "schedule" {
name = "schedule"
description = "Schedule for Lambda Function"
schedule_expression = var.schedule
}
resource "aws_cloudwatch_event_target" "schedule_lambda" {
rule = aws_cloudwatch_event_rule.schedule.name
target_id = "processing_lambda"
arn = aws_lambda_function.processing_lambda.arn
}
resource "aws_lambda_permission" "allow_events_bridge_to_run_lambda" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.processing_lambda.function_name
principal = "events.amazonaws.com"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment