aws-cdk There is already a Construct with name; when trying to create multiple instances of same construct

Viewed 1745

I want to do something like following in the AWS CDK.

const a = new RandomObject(this, 'randomValue1', 'randomValue2').lambdaFunction;
const b = new RandomObject(this, 'randomValue111', 'randomValue2222').lambdaFunction;

However, CDK complains that "There is already a Construct with name 'RandomObject' in InfraStack"

Is there a way achieve what I am trying to do?

Context : I have a stepFunction that I want to dynamically create by passing 2 variables 'randomValue1' and 'randomValue2'. The randomValue1 will be the name of the step function and randomValue2 will be the trigger of lambda function inside of it. Keeping everything else the same. I want to avoid creating multiple Constructs for the same state machine if I can.

0 Answers
Related