Does anyone know if there's a method to determine whether a module is executing in the context of a Pulumi run? My use case is that I'm writing a library that will be used both by Pulumi, as well as other non-Pulumi code. If it's being called from Pulumi I want to automatically wrap the output in an
10/16/2021, 10:56 AM
It is possible to get caller context with examining stack frame objects in python (for example via inspect module). However I can't recommend it because it is considered as a hack and also typecheck software won't work. The better way is to wrap a result explicitly from pulumi program or call different method for some more complex scenarios.