https://pulumi.com logo
Title
c

creamy-guitar-8902

05/12/2023, 10:49 PM
Does anyone have a good example of in-lining (not sure if this is the proper term) some standard python during
pulumi up
"actual run" runs ?
I've currently got a simple
__main__.py
that's just pulumi calls but I wand to verify some outputs and make some potential changes with native google cloud python library calls as well
It caught me off-guard that those python commands I wrote ran during the diagnostics phase as well, which of course didn't work because I was relying on the pulumi functions to have actually executed first 🙂
After thinking about it more though, it makes sense that my calls would execute during the diagnostics phase as well. So what I really want to know is how to make my bespoke python execute only after particular pulumi functions have executed "for real" (not a dry run)
any help would be appreciated!
Also, hi @white-balloon-205 ! Pinecone here 🙂
e

elegant-carpet-82808

05/12/2023, 11:04 PM
You can inline pulumi code in your python code using the automation api: _(https://github.com/pulumi/automation-api-examples/tree/main/python/inline_program)_
c

creamy-guitar-8902

05/12/2023, 11:24 PM
haha, I was worried that'd be the standard response
Is that the only way to do it?
r

red-match-15116

05/12/2023, 11:56 PM
nah, you can also run any old code during your regular
pulumi up
, you can check if it's a preview with
isDryRun
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/runtime/#isDryRun
c

creamy-guitar-8902

05/12/2023, 11:57 PM
That's exactly what I was looking for, thank you @red-match-15116!
r

red-match-15116

05/12/2023, 11:58 PM
wait you're using python, but yeah the same function (
is_dry_run
) also exists in the python sdk