thankful-painting-31068
04/03/2025, 4:36 PMB
in stack A
.
Typical chicken and egg problem.
One possible solution is to reference the stack and on the first deployment, do not create the resources that need the front door resource id since it does not exist.
On the 2nd deployment, create the resources now that the stack (and the front door id output is available).
The issue I seem to hit has that uses a stack reference causes an error that I cannot avoid:
try {
const stackRef = new StackReference(`org/project/stack`);
const frontDoorId = test.getOutput("frontDoorId");
console.log(frontDoorId);
} catch (error) {
console.log(error);
console.log("Stack does not exist yet. Will retry on next deployment.");
}
Every preview I run fails due to:
error: Preview failed: unknown stack "org/project/stack"
thankful-painting-31068
04/04/2025, 1:06 PMthankful-painting-31068
04/08/2025, 4:38 PMechoing-dinner-19531
04/08/2025, 8:09 PMechoing-dinner-19531
04/08/2025, 8:10 PMthankful-painting-31068
04/09/2025, 9:47 PMthankful-painting-31068
04/09/2025, 9:48 PMare all tricky related problems we keep thinking about🙏🏽 I know it's not easy to solve. Thanks.