On adding target(LambdaFunction) to Event Rule in AWS-CDK in java giving error: There is already a Construct with name lambda_name in stack
On adding target(LambdaFunction) to Event Rule in AWS-CDK in java giving error: There is already a Construct with name lambda_name in stack
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 对象
您是否尝试过命名空间或为您的函数名称添加前缀?如果在同一个堆栈中有另一个同名的 lambda 函数,那么这个错误听起来好像会出现。
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 对象
您是否尝试过命名空间或为您的函数名称添加前缀?如果在同一个堆栈中有另一个同名的 lambda 函数,那么这个错误听起来好像会出现。