Reputation: 3
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));
On doing this it's giving below error
Caused by: software.amazon.jsii.JsiiException: There is already a Construct with name 'lambda-name' in Stack
Don't know how to typecast Function to IRuleTarget or How to convert function to IRuleTarget object
Upvotes: 0
Views: 1998
Reputation: 102
Have you tried namespacing or adding a prefix to your function name? That error sounds like it comes up if there is another lambda function with the same name in the same stack.
Upvotes: 1