Reputation: 6271
I am fairly new to typescript CDK for aws and am trying to deploy a lambda function using CDK in typescript with something like this:
const lambdaFn = new lambda.Function(..);
Now, I am trying to create an event rule which needs to trigger this lambda function. When I add the targets
part (shown below) in the rule, I see an error shown below.
const rule = new events.Rule(
this,
'Rule',
{
eventPattern: {"source": [ "aws.organizations" ], "detail": { "eventName": [ "CreateAccountResult" ] } },
targets: [ new targets.LambdaFunction(lambdaFn) ] // <<<--- this line throws exceptions..
}
);
Exception I see:
lib/test.ts:26:20 - error TS2322: Type 'LambdaFunction' is not assignable to type 'IRuleTarget'.
Types of property 'bind' are incompatible.
Type '(rule: IRule, _id?: string | undefined) => RuleTargetConfig' is not assignable to type '(rule: IRule, id?: string | undefined) => RuleTargetConfig'.
Types of parameters 'rule' and 'rule' are incompatible.
26 targets: [ new targets.LambdaFunction(lambdaFn) ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..
..
..
lib/test.ts:26:47 - error TS2345: Argument of type 'Function' is not assignable to parameter of type 'IFunction'.
Types of property 'role' are incompatible.
Type 'import("/home/shubham/workspace/ft/organization-management-services/node_modules/@aws-cdk/aws-iam/lib/role").IRole | undefined' is not assignable to type 'import("/home/shubham/workspace/ft/organization
..
..
26 targets: [ new targets.LambdaFunction(lambdaFn) ]
~~~~~~~~
What am I missing?
Upvotes: 0
Views: 2259
Reputation: 6271
This was a known issue that's documented here: https://github.com/aws-samples/aws-cdk-examples/issues/89
Upvotes: 1