Hey Guys, I would like to disable a possibility to...
# dotnet
d
Hey Guys, I would like to disable a possibility to perform Pulumi UP in any form. I know that there is Deployment.Instance.IsDryRun but I would like to exclude this possibility at the start of the program so I don't have to modify the stacks. An example in program.cs
Copy code
if (Environment.GetEnvironmentVariable("PULUMI_DRY_RUN") == "true")
{
    return await Deployment.RunAsync<Stack>();
}
else
{
    throw new NotSupportedException("Pulumi command is not supported");
}
The problem with this approach is, the preview is called first with the variable set on true and it never gets back to this context. Is there a way to get info what command was invoked ?
e
The problem with this approach is, the preview is called first with the variable set on true and it never gets back to this context
It should. I'm pretty sure the program gets invoked twice, once for preview, once for the actual up and it starts the whole program from scratch each time.
g
@damp-smartphone-91507 - I've tested the above code and it works to only give a preview result if you run
pulumi preview
or if you run
pulumi up
. As fraser mentioned if
pulumi up
is run without
--skip-preview
(of
-if
) if will run the preview first but then not deploy. It's worth bearing in mind that I don't believe this would stop
pulumi destroy
from being run as this does not typically execute the program during destroy.