Hey all, is there a way to get if the calling comm...
# python
f
Hey all, is there a way to get if the calling commando is
up
,
destroy
or
preview
during execution? Can’t sort this out and was wandering how to use
lambda_.get_invocation
to differ what to do in each case
g
Hm. You could try using the Automation API to get that data; the call would be one of the arguments in the
args
list. For example: https://github.com/pulumi/automation-api-examples/blob/main/python/local_program/automation/main.py
👍 1
f
hmm… nice thought, @great-queen-39697! I think that will be a good way to go! Thanks 🙂
🙌 1
m
Another option would be to use
pulumi.runtime.is_dry_run()
— that’ll tell you whether the current execution is a preview (true) or an update (false): https://www.pulumi.com/docs/reference/pkg/python/pulumi/#pulumi.runtime.is_dry_run
I don’t know if there’s a way to programmatically detect a destroy, though. 🤔