首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在golang中使用CDK将目标添加到CloudWatch事件规则

在golang中使用CDK将目标添加到CloudWatch事件规则
EN

Stack Overflow用户
提问于 2021-02-01 13:37:02
回答 1查看 1.2K关注 0票数 0

我是aws的typescript CDK的新手,我正在尝试在typescript中使用CDK部署一个lambda函数,如下所示:

代码语言:javascript
复制
const lambdaFn = new lambda.Function(..);

现在,我正在尝试创建一个需要触发这个lambda函数的事件规则。当我在规则中添加targets部件(如下所示)时,我看到如下所示的错误。

代码语言:javascript
复制
const rule = new events.Rule(
  this,
  'Rule',
  {
    eventPattern: {"source": [ "aws.organizations" ], "detail": { "eventName": [ "CreateAccountResult" ] } },
    targets: [ new targets.LambdaFunction(lambdaFn) ] // <<<--- this line throws exceptions..
  }
);

我看到了异常:

代码语言:javascript
复制
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) ]
                                                 ~~~~~~~~

我遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2021-02-02 02:29:59

这是一个已知的问题,记录在这里:https://github.com/aws-samples/aws-cdk-examples/issues/89

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65987649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档