https://pulumi.com logo
#automation-api
Title
# automation-api
l

little-orange-65618

07/01/2023, 2:20 AM
Hello, using the automation API I'm trying to handle a resource.get and catch it for when it doesn't exist. I've gotten it to process the except block but the program then stopped building the stack, code below:
try:
user = Output(ccloud.get_user_output(email=config['email'])).apply(lambda user: user)
id = IdHolder(user.id)
return id
except:
inv = ccloud.Invitation(resource_name=name, email=config['email'], opts=ResourceOptions(retain_on_delete=True))
id = IdHolder(inv.users[0].id)
return id
The use case is, see if a user exists if not send an invite. Wrapping the .get_user_output() call with a Output() finally lets the except block execute, creating the invitation, but then the program stops no other resources are created
ccloud is the Pulumi_ConfluentCloud extension
Ok looking at it, the exception that allowed it to process the exception block was that I couldn't directly invoke user.id on an output so it was a bit of a red herring. The issue seems to be not being able to catch Pulumi_ConfluentCloud exceptions