5

Is there a way with Pulumi to access the current stack name in order to chose which class to run when doing pulumi up?

I want to do something like that:

static Task<int> Main()
{
    if (Deployment.Instance.StackName.StartsWith("local-"))
        return Deployment.RunAsync<LocalStack>();

    return Deployment.RunAsync<AzureStack>();
}
JuChom
  • 5,717
  • 5
  • 45
  • 78

1 Answers1

4

Deployment.Instance is not available before you execute RunAsync, which you already figured out.

As a workaround, you could get the stack name from the environment variable:

Environment.GetEnvironmentVariable("PULUMI_STACK")

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107