Hey Team, is there any way to lookup for the exist...
# typescript
f
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
You can use the SDK provided by the appropriate cloud provider.
s
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
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?