Does anyone have a good example of in-lining (not ...
# python
c
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
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
haha, I was worried that'd be the standard response
Is that the only way to do it?
r
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
That's exactly what I was looking for, thank you @red-match-15116!
r
wait you're using python, but yeah the same function (
is_dry_run
) also exists in the python sdk