I want to configure CloudWatch Events to send input to Lambda function with Terraform. I have used the following script to do so:
resource "aws_cloudwatch_event_rule" "aa-rule-event" {
count = "${var.count}"
name = "${var.application_name}-${element(var.names, count.index)}"
description = "${element(var.descriptions, count.index)}"
schedule_expression = "${element(var.cron-expressions, count.index)}"
is_enabled = "${element(var.rule-status-states, count.index)}"
}
resource "aws_cloudwatch_event_target" "aa-rule-target" {
count = "${var.count}"
rule = "${var.application_name}-${element(var.names, count.index)}"
target_id = "CloudWatchToLambda"
arn = "arn:aws:lambda:${var.aws_region}:${var.aws_account_number}:function:${var.application_name}-${element(var.target-lambda-function, count.index)}"
}
I need to give an input to the target Lambda through this CloudWatch Event. I know the input can be configured but how do I configure that in Terraform?