Hi, is there a way catch StackReference errors (i....
# general
Hi, is there a way catch StackReference errors (i.e. if it doesn’t exist, handle the error rather than interrupting the deployment process)?
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.
OK thanks