我是aws的typescript CDK的新手,我正在尝试在typescript中使用CDK部署一个lambda函数,如下所示:
const lambdaFn = new lambda.Function(..);现在,我正在尝试创建一个需要触发这个lambda函数的事件规则。当我在规则中添加targets部件(如下所示)时,我看到如下所示的错误。
const rule = new events.Rule(
this,
'Rule',
{
eventPattern: {"source": [ "aws.organizations" ], "detail": { "eventName": [ "CreateAccountResult" ] } },
targets: [ new targets.LambdaFunction(lambdaFn) ] // <<<--- this line throws exceptions..
}
);我看到了异常:
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) ]
~~~~~~~~我遗漏了什么?
发布于 2021-02-02 02:29:59
这是一个已知的问题,记录在这里:https://github.com/aws-samples/aws-cdk-examples/issues/89
https://stackoverflow.com/questions/65987649
复制相似问题