I want to add a Lambda target to an existing CloudWatch rule. I used the following to refer to the existing rule:
rule = events.Rule.from_event_rule_arn(self, "Rule",event_rule_arn='')
Later I add a target with:
rule.add_target(targets.LambdaFunction(lambdaFn))
When I execute a cdk synth
or deploy
, I get the following error:
AttributeError: '+' object has no attribute 'add_target'
I know the IRule
element does not have that method but I cannot find a clear way how to achieve what I need.
I also try using event source in Lambda but got the following error:
Unrecognized event source, must be kinesis, dynamodb stream or sqs.