Is there a way to find out if the `--skip-preview`...
# automation-api
c
Is there a way to find out if the
--skip-preview
flag was passed in your pulumi application?
b
Idk if you’ve figured this out already - but no there is not. There is however a way to check if the current run is a preview within your Pulumi program using the IsDryRun boolean
c
I did not, the problem is the automation API skips preview and my resource uses isDryRun I basically want to use dryRun if preview ran, but if preview was skipped I need it to run in the main process
b
I’m confused. You’re saying your Pulumi program relies on a preview being executed first? That sounds like a larger problem
c
I have a
BuildStep
resource, similar to the build docker image helpers, I was hoping that if say a project fails to build that would happen in preview
But not have to rebuild during up
b
There’s nothing preventing you from running a preview first using Automation API. It just doesn’t do it as part of an Up
c
Totally, that is our work around, but in general was thinking it could be good to skip that as it saves time
b
So you would like to fail prematurely during preview, but you would also like to skip preview to save time?
c
If you preview, then yes, would like it to fail early there
But if you have chosen to skip, then do it part of the up
Will likely just move it so it only builds during
up
, rather than preview.
b
Oh I see. You were using IsDryRun to take action that was only occurring during a preview. Yes I would call that a problem. You should use IsDryRun == true only to decide to not take action, not to decide that you should take action
Since previews and ups are independent actions, up can have no knowledge of whether or not a preview was executed first, they are 2 separate invocations. You could do something really weird with automation api like pass in your stack history when using an inline program.. but like I said, that would be really weird
c
Yeah fair enough, that was the direction I was going to take. Just build during up, not preview
Safer all around