---
name: debug-pulumi-failed-operation
description: "Reads a failed Pulumi update or preview from the recorded engine events and says whether the fix is the program, the state, or the credentials. Use when the user wants to debug a failed pulumi up, a failed pulumi preview, or an update that stopped halfway. New infrastructure is a different task."
license: Apache-2.0
metadata:
  category: debugging
  tags: "pulumi,infrastructure"
  author: johnny-bravo
  version: "1.0"
  updated: "2026-11-25"
  status: published
  aliases: "pulumi up, pulumi preview, engine events, pulumi refresh"
  source_url: "https://github.com/pulumi/agent-skills/blob/60a692fb61cd61aeb39c3488de54f065eecea591/pulumi/skills/pulumi-debug-failed-operation/SKILL.md"
  source_license: Apache-2.0
  copyright: "Copyright [yyyy] [name of copyright owner]. The pulumi/agent-skills LICENSE keeps that Apache template line unfilled. Attribute this skill to Pulumi (pulumi/agent-skills)."
  original_author: "Pulumi (pulumi/agent-skills)"
  modified: "Modified by TheSkillVault on 2026-11-25. Rewritten as a short failure guide. The read-the-record order is kept. Authoring, migration, and provider-upgrade steps were not copied. Not the original file."
  imported_on: "2026-11-25"
---

# Debug a failed Pulumi operation

Pulumi already stored the error when the update or preview failed. Read that record. Do not run `pulumi up` or `pulumi preview` again just to see the same text.

`pulumi api` talks to Pulumi Cloud. Pass the stack as `{org}/{project}/{stack}`. You do not need that stack selected locally to read the record. You do need it selected later, when you apply a fix.

## When to use
- The user points at a failed `pulumi up` or `pulumi preview`.
- They give an org, project, stack, and an update version or a preview id.
- An update stopped halfway and some resources may already have changed.

## When not to use
- The user wants new infrastructure written. That is authoring, not this failure.
- The user wants a migration from Terraform or CloudFormation. That is a different task.
- The user wants a provider upgrade. Do not fold that into the fix.

## Steps
1. Collect org, project, stack, and the update version or preview id. Take a missing name from `pulumi stack --show-name`, `pulumi stack ls`, or `Pulumi.yaml`. A missing version means the latest update on that stack.
2. Tell the user which operation you will read. Include the version or preview id and the stack. Wait for a yes if you had to guess the operation.
3. If they named no operation, find their latest one. Run `pulumi whoami`. Read `updates/latest` and compare `requestedBy.githubLogin` with that login. Walk back one version at a time until the login matches. Confirm that operation before you go on.
4. Fetch the engine events. For an update, use the `update/<version>/events` path. For a preview, use the `preview/<preview-id>/events` path. Pull each `diagnosticEvent` message. Strip the `<{%reset%}>` color codes.
5. Read every diagnostic, not only `severity == "error"`. A provider error is tagged `error`. A program error on a preview often arrives as stderr tagged `info#err`.
6. For each error, name the resource URN and type, the file that declares it, and the inputs that feed it.
7. Say where the fix belongs. The program: bad code, a wrong type, or a value used before it resolved. The state: the code is right and the cloud disagrees. The environment: a credential, a permission, OIDC, or a quota.
8. Make the smallest change for that cause. For state drift, `pulumi refresh` reconciles. `pulumi import` adopts a resource that already exists. Say what each command will change before you run it. An update that failed halfway may have already changed some resources. Check current state first.
9. If the diagnostic is empty, the real error is often in the log of the command the resource ran. Read that log. If you need a token or a run you cannot see, stop and ask for the one thing you need.
10. Do not paste a Pulumi access token, a cloud key, or a stack password into chat. Do not put one in the repo.

## Read the record
```
pulumi api /api/stacks/{org}/{project}/{stack}/update/<version>/events
```

Use the preview path when the failure was a preview. Keep the org, project, and stack in the path you were given. Do not switch stacks to make the command shorter.

## Gotchas
- Selecting the wrong stack and running `pulumi up` creates a new failure. Read first.
- `info#err` is still a failure. Filtering to `severity == "error"` hides the common preview bug.
- `pulumi refresh` and `pulumi import` change state. They are not read-only.
- A quota or an IAM denial is not fixed by editing the resource code.

## Portability
Works with any language Pulumi supports. The event record is the same for TypeScript, Python, Go, C#, Java, or YAML. If you are using Terraform or another tool, this record does not exist. Do not invent a Pulumi stack to hold that error.

## Example prompt
"Debug update 161 of stack vvm-dev. Read the recorded diagnostics, including info#err, and tell me if the fix is the program, the state, or the credentials. Do not run pulumi up again."

## Done when
- You named the operation, the stack, and the version or preview id before editing.
- You read the stored diagnostics, including `info#err`.
- Each error is tied to a resource and to one of program, state, or environment.
- Any refresh or import was described before it ran.
- No token or cloud key was pasted into chat or committed.
- You did not re-run the failed update just to reprint the error.

---
Modified from "pulumi-debug-failed-operation" in pulumi/agent-skills (Apache-2.0). Attribute to Pulumi (pulumi/agent-skills). The upstream LICENSE keeps the unfilled template line. See LICENSE.txt.
