【发布时间】:2020-10-12 09:29:27
【问题描述】:
Function lambdaFun =
Function.Builder.create(this, LAMBDA_NAME)
.runtime(Runtime.JAVA_11)
.code(LambdaCode)
.functionName(LAMBDA_NAME)
.handler("handler_xyz")
.role(role)
.memorySize(3008)
.timeout(Duration.minutes(15))
.environment(LAMBDA_ENV)
.build();
Rule rule =
Rule.Builder.create(this, CWE_NAME)
.schedule(Schedule.rate(Duration.seconds(60)))
.description("CloudWatch Event")
.build();
rule.addTarget(new LambdaFunction(lambdaFun));
这样做会出现以下错误
Caused by: software.amazon.jsii.JsiiException: There is already a Construct with name 'lambda-name' in Stack
不知道如何将函数类型转换为 IRuleTarget 或如何将函数转换为 IRuleTarget 对象
【问题讨论】:
-
目前使用CDK 1.45.0版
标签: amazon-web-services aws-lambda amazon-cloudformation aws-cdk