sticky-answer-6826
06/01/2022, 10:29 PMstack
=
new
pulimi.StackReference(stackName)
. More specifically the errors occurs after that but before the next line that follows myOutput
=
await
stack.requireOutputValue(‘myVal’)
.
The error is “Duplicate resource URN ‘`urnpulumicurrentStack:currentProjectpulumipulumi:StackReference:stackINeed`’”.
When I only loop one set of resources, pulumi
preview
works fine. It is when I have 2 resources that iterate through the loop that I get the error. Hence, I can only attribute it to trying to get a reference to the stack that already exists in the current state of running pulumi preview
.
Am I way off in my thought?
Thanks!little-cartoon-10569
06/01/2022, 10:37 PMif (stackName == pulumi.getStack())
) and then continue
.sticky-answer-6826
06/02/2022, 12:33 AMpulumi preview
or pulumi
up
and as the stack is being evaluated to know what to do (create/delete resources), I can't call a new StackReference on the same stack. That's where the collision happens.little-cartoon-10569
06/02/2022, 1:18 AMsticky-answer-6826
06/02/2022, 3:04 AMpulumi preview
because the internal state of this preview already had this stack reference called:
for (config of configs) {
const stack = new pulumi.StackReference(stackInOtherProject);
// exits here with Duplicate resource URN error
const outputVal = await stack.requireOutputValue(‘myVal’);
// some code here that is reached by config[0] but not config[1]
}
little-cartoon-10569
06/02/2022, 3:32 AM