https://pulumi.com logo
#typescript
Title
# typescript
c

curved-eye-56312

05/30/2023, 8:26 AM
Hello #typescript, I have an issue with error handling. I would like to create a private link only if the key vault resource already exists. Is it possible to develop a try-catch statement to catch any error that may occur so that the pulumi execution does not fail? It should be okay if the resource does not exist, the PE should just not be created. Is this a possibility? Also, is it possible to validate this in resources from other Azure subscriptions?
a

astonishing-exabyte-93491

05/30/2023, 7:47 PM
What you describe seems pretty feasible at first glance, but a bit of context would be helpful to better understand what your goals are. Also don’t forget there’s an #azure channel if you need specific guidance.
l

little-cartoon-10569

05/30/2023, 8:38 PM
It sounds like you want to catch an exception that would be thrown at deploy time. You can do this only if you have a Pulumi program specifically for this resource, which is probably not what you want. You Pulumi code does not deploy any resources: it builds the data that the Pulumi engine uses to deploy the resources. Exceptions thrown during deploy time would be caught by the engine, after your code has finished running. A better pattern for this might be to import the resource before running your program, so that your code is correct and does not have to know if the resource already exists.
2 Views