https://pulumi.com logo
#general
Title
# general
m

most-lighter-95902

12/29/2021, 12:06 AM
Hi, is there a way catch StackReference errors (i.e. if it doesn’t exist, handle the error rather than interrupting the deployment process)?
b

bored-oyster-3147

12/29/2021, 12:24 AM
Since Pulumi functions via desired state, that means it doesn't actually make any cloud provider or api calls until after it has executed through your desired state, built your dependency tree, and determined ordering etc. This means the exception for a missing stack isn't thrown when your StackReference is instantiated, it is thrown later after the dependency tree is built when the Pulumi engine is processing that tree to reach your desired state. So the instantiation itself is executing to completion without error. I don't think this is possible without you catching the exception outside of your pulumi up call, making some change, and then invoking Pulumi again. Which would require Automation API.
Alternatively you could yourself check if the stack exists ahead of time and do whatever you want.
m

most-lighter-95902

12/30/2021, 11:24 PM
OK thanks
10 Views