Skip to content

Pulumi Automation API Stack Not Found

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about Pulumi Automation API Stack Not Found. We cover key concepts, practical examples, and best practices.

The Pulumi Automation API throws 'stack not found' errors even after the stack is created.

Wrong ❌

// Wrong: using a stack without creating or selecting it first
import { LocalWorkspace } from "@pulumi/pulumi/automation";

async function deploy() {
  const workspace = await LocalWorkspace.create({});
  const stack = await workspace.selectStack("dev"); // Stack does not exist
  await stack.up();
}

Wrong Output

Error: stack 'dev' does not exist
    at LocalWorkspace.selectStack (automation/index.js:...)
Available stacks: []
import { LocalWorkspace } from "@pulumi/pulumi/automation";

async function deploy() {
  const workspace = await LocalWorkspace.create({
    projectSettings: {
      name: "my-project",
      runtime: "nodejs",
    },
    program: async () => {
      const bucket = new aws.s3.Bucket("my-bucket");
      return { bucketName: bucket.bucketName };
    },
  });

  // Create or select the stack
  const stack = await workspace.createStack("dev");
  // Or: const stack = await workspace.selectStack("dev");

  // Configure the stack
  await stack.setConfig("aws:region", { value: "us-east-1" });

  // Deploy
  const result = await stack.up({ onOutput: console.log });
  console.log(`Deploy complete: ${result.outputs.bucketName.value}`);
}

Right Output

Deploying stack 'dev'...
  + aws:s3:Bucket "my-bucket" created
Deploy complete: my-bucket-abc123

Prevention

  • Use createStack() for new stacks, selectStack() only for existing stacks.
  • Initialize LocalWorkspace with projectSettings when no Pulumi.yaml exists.
  • Set required configuration values (like aws:region) before calling stack.up().
  • Handle the StackAlreadyExists error when createStack is called on an existing stack.
  • Use onOutput callback to stream deployment logs in real-time.

DodaTech applies similar defensive patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro infrastructure for production reliability.

Common Mistakes with automation api

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world PULUMI code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

**Q: What is the most common cause of this pulumi error?**

A: Configuration drift between environments and version mismatches between the client and server are the top causes. Always verify both before deeper troubleshooting.

Q: Can this error affect production traffic?

A: Yes. Depending on whether the error occurs in the control plane or data plane, it can block all traffic or cause silent failures. Always test configuration changes in a staging environment first.

Q: How do I monitor for this error in production?

A: Set up log-based alerts for the error signature shown in the Wrong Output section. Prometheus, Grafana, and Datadog all support pattern matching on log entries.

Q: Is there a quick rollback procedure?

A: If you have the previous configuration version, revert and restart. For data-plane errors, replay affected records from the source of truth. Always version control your configuration.


This quick fix is part of the DodaTech infrastructure engineering series. Learn more at DodaTech tutorials.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro