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

clever-hair-26722

09/17/2022, 4:38 PM
Hello all, I am looking for a solution to wait until a resource is created to run an additional script. (python, azure-native)
g

gorgeous-accountant-60580

09/17/2022, 4:45 PM
Can’t say if this is a good fit without knowing what sort of resource, but we do something possibly similar when we create databases. There were inject a secret with the connection string into k8s, which we can then depend on. When the secret is created, the db is sure to be ready.
c

clever-hair-26722

09/17/2022, 4:48 PM
in my case i need to wait for a disk encryption set. how did you solve it?
g

gorgeous-accountant-60580

09/17/2022, 4:49 PM
I’m not sure how I would block on something like that, I’m afraid.
c

clever-hair-26722

09/17/2022, 4:51 PM
i can build try/catch around it and retry until it is successful, but this seems like a “dirty” solution to me
what is your approach with your database?
g

gorgeous-accountant-60580

09/17/2022, 5:02 PM
We create the database, and some users for it, and inject credentials for those users into a k8s secret. The application that depends on the database can then wait for the secret to be created.
c

clever-hair-26722

09/17/2022, 5:04 PM
sounds similar to what i am trying to achive. how do you wait until the database is created?
g

gorgeous-accountant-60580

09/17/2022, 5:06 PM
Do you mean how to wait for the database being created, before creating the secret? Since the secret, which is created by pulumi as well, depends on output variables from the database creation, that is handled implicitly.
Any time you use an output variable from one resource as an input variable in the creation of another resource, pulumi is aware of the dependency between those resources
In that sense, you could also use pulumi to create a k8s job, and express the dependency between the resource you’re creating and the job. You might have to do that manually, using
DependsOn
, unless there’s an actual output variable you would use as input. Any other way of running a script, such as creating a VM, should also work for this. https://www.pulumi.com/docs/intro/concepts/resources/options/dependson/
c

clever-hair-26722

09/17/2022, 5:14 PM
ah, okay. in your case depends on is the way to go.
g

gorgeous-accountant-60580

09/17/2022, 5:15 PM
c

clever-hair-26722

09/17/2022, 5:15 PM
yes, exactly
g

gorgeous-accountant-60580

09/17/2022, 5:16 PM
I would think that some other resource can depend on this using DependsOn just as well as any other resource in pulumi
c

clever-hair-26722

09/17/2022, 5:17 PM
my root issue is, that i have to grant this encryption set access on an key vault that is unfortunately not managed by pulumi and the automation api does not yet support importing resources, only the pulumi cli
b

billowy-army-68599

09/17/2022, 7:28 PM
@clever-hair-26722 anything that happens inside an
apply
block happens after the outputs for that resource have resolved. So if you want to do something when a resource is created:
Copy code
myresource.output..apply(
           lambda variable: // do somehting here
        )
👍 1
c

clever-hair-26722

09/18/2022, 7:49 AM
nice.. i will try that. thank you for the hint! 🙂
2 Views