Skip to content
DevOps AI ToolKit
Newsletter
All guides
AI for Pulumi By James Joyner IV · · 8 min read

Pulumi Error: 'stack dev already exists' — Cause, Fix, and Troubleshooting Guide

Quick answer

Fix Pulumi 'stack dev already exists' by selecting the existing stack instead of pulumi stack init, or choosing a new unique stack name.

  • #pulumi
  • #iac
  • #troubleshooting
  • #errors
Free toolkit

Fixing errors like this? Get 500 free DevOps AI prompts

500 copy-paste AI prompts for the stack you actually run — one PDF, free.

Overview

error: stack 'dev' already exists means you ran pulumi stack init dev for a stack name that is already present in the current backend and project. Pulumi will not overwrite existing stack state, so stack init refuses when the name is taken. This is a guard against accidentally clobbering an existing environment’s state.

The most common trigger is a CI pipeline that always runs pulumi stack init on every run, or a developer re-initializing a stack that a teammate already created. The fix is almost always to select the existing stack rather than create it again.

error: stack 'dev' already exists

Symptoms

  • pulumi stack init dev fails with stack 'dev' already exists.
  • A CI job that unconditionally runs pulumi stack init fails on the second and later runs.
  • pulumi stack ls already lists dev.
  • You intended a fresh stack but reused a name that a colleague created.

Common Root Causes

1. The stack was already initialized

Someone (or a previous pipeline run) already ran pulumi stack init dev, so the name is taken in this backend/project.

pulumi stack ls

2. CI runs stack init unconditionally

Automation that always calls pulumi stack init dev succeeds the first time and then fails on every subsequent run.

pulumi stack init dev   # fails once dev exists

3. You meant to select, not create

You want to operate on the existing stack; stack init is only for creating a brand-new one.

4. Name collision on a shared backend

On Pulumi Cloud, stack names live under <org>/<project>. Another team member already created dev in the same org/project.

5. Leftover state from an incomplete cleanup

A prior stack was not fully removed (pulumi stack rm was interrupted), leaving the name reserved.

How to Diagnose

List existing stacks to confirm dev is really there:

pulumi stack ls

Check the fully-qualified names on Pulumi Cloud:

pulumi stack ls --all

See which stack is currently selected:

pulumi stack --show-name

Confirm backend and identity so you know where the collision lives:

pulumi whoami --verbose

Fixes

Select the existing stack instead of creating it: This is the usual intent.

pulumi stack select dev

Make CI idempotent: Select the stack, and only initialize it if selection fails.

pulumi stack select dev || pulumi stack init dev

Choose a different, unique name: If you genuinely need a new environment, pick an unused name.

pulumi stack init dev2
# or fully-qualified on Pulumi Cloud
pulumi stack init myorg/myproject/dev-feature-x

Remove the old stack first (destructive): Only if you truly want to discard the existing stack and its state. Destroy resources first to avoid orphans.

pulumi destroy --stack dev
pulumi stack rm dev
pulumi stack init dev

Reuse the intended backend/project: If the collision is unexpected, verify you are in the right project directory and backend before deciding.

cat Pulumi.yaml
pulumi whoami --verbose

What to Watch Out For

  • pulumi stack rm deletes stack state; run pulumi destroy first or you will orphan cloud resources that Pulumi no longer tracks.
  • In pipelines, prefer pulumi stack select <name> || pulumi stack init <name> so first and subsequent runs both work.
  • Stack names are unique per backend and project — the same name can safely exist under a different org or project.
  • pulumi stack init never overwrites; it only creates. Re-running it is not a way to “reset” a stack.
  • After pulumi stack rm, allow a moment before re-init on cloud backends to ensure the name is fully released.
  • Use --stack flags in automation to avoid depending on whichever stack happens to be selected.
Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.