I am struggling to create a schedule to run a lambda function through terraform…
With the code below
resource "aws_lambda_function" "cleansing_coding_lambda" {
...
}
resource "aws_cloudwatch_event_rule" "cleansing_coding_rule" {
name = "cleansing-coding-rule"
schedule_expression = "cron(5 * * * ? *)" # every hour, 5 mns passed the hour
}
resource "aws_cloudwatch_event_target" "cleansing_coding_target" {
rule = aws_cloudwatch_event_rule.cleansing_coding_rule.name
arn = aws_lambda_function.cleansing_coding_lambda.arn
}
I can see that the Amazon Eventbridge rule is created.
Its schedule is set
Its target is configured to the lambda function bfe-dp-dev-triggerMatillionCleansingCoding which is correct.
However, when I look at the lambda function bfe-dp-dev-triggerMatillionCleansingCoding, it does not appear to be linked to a “EventBridge (CloudWatch Events)”.
I still need to manually add a “trigger” to “Eventbridge (CloudWatch Events)” where I do retrieve my rule “cleansing-coding-rule”.
Am I missing a step/trick in terraform?
Thanks