https://pulumi.com logo
Title
f

flaky-notebook-65308

03/24/2023, 1:36 AM
Hey Team, is there any way to lookup for the existence of a resource without the function actually throwing an error? For context - I am trying to get
getUserAssignedIdentityOutput
but it errors out and the error seems to be not catchable. Maybe relatable - https://github.com/pulumi/pulumi/issues/3364
l

little-cartoon-10569

03/24/2023, 3:38 AM
You can use the SDK provided by the appropriate cloud provider.
s

stocky-restaurant-98004

03/24/2023, 2:37 PM
In addition to Paul's excellent suggestion, some resource types also have functions that are designed to return multiple matches, e.g.
aws.ec2.getSubnets()
. You could pass it criteria that should return exactly one if it matches.
f

flaky-notebook-65308

03/26/2023, 9:30 AM
Thank you. I am doing exactly that with getUserAssignedIdentityOutput. However I wanted to catch the error (when the resource doesn’t exist) but the function itself isn’t catchable. Was wondering if there was any other way to approach this?