pulumi/pulumi · error
resources file references %q as %s, but that resource was no
Error message
resources file references %q as %s, but that resource was not found in the stack
What it means
Every name in the resources file must correspond to a resource present in the target stack snapshot. If the URN is not found among snapshot states, the whole reference resolution aborts with this error naming the resource and URN.
Source
Thrown at pkg/cmd/pulumi/do/do_resource_upsert.go:575
continue
}
statesByURN[state.URN] = state
if sdkproviders.IsProviderType(state.Type) {
ref, err := sdkproviders.NewReference(state.URN, state.ID)
if err != nil {
return nil, fmt.Errorf("could not build provider reference for %s: %w", state.URN, err)
}
providersByRef[ref.String()] = state
}
}
}
refs := make(map[string]plugin.ConvertSnippetResourceReference, len(resources))
for name, rawURN := range resources {
urn := resource.URN(rawURN)
state, ok := statesByURN[urn]
if !ok {
return nil, fmt.Errorf("resources file references %q as %s, but that resource was not found in the stack", name, urn)
}
typ := state.Type
pkg := typ.Package()
if sdkproviders.IsProviderType(typ) {
pkg = sdkproviders.GetProviderPackage(typ)
}
packageReq := &codegenrpc.GetSchemaRequest{
Package: string(pkg),
}
providerState, err := resourceReferenceProviderState(state, providersByRef)
if err != nil {
return nil, fmt.Errorf("resources file reference %q: %w", name, err)
}
if providerState != nil {
providerPackage := sdkproviders.GetProviderPackage(providerState.Type)
schemaPackage, err := deployproviders.GetProviderName(providerPackage, providerState.Inputs)View on GitHub (pinned to 793f7b2e16)
Solutions
- Regenerate the resources file against the current stack so all URNs exist.
- Confirm the intended stack is selected (--stack flag) and matches where the resources file was produced.
- Remove stale entries from the resources file for resources no longer in the stack.
Example fix
// before (stale entry)
{"old-bucket": "urn:pulumi:stg::proj::aws:s3/bucket:Bucket::old-bucket"}
// after (removed)
{"my-bucket": "urn:pulumi:stg::proj::aws:s3/bucket:Bucket::my-bucket"} Defensive patterns
Strategy: validation
Validate before calling
exported, _ := pc.exportStack(ctx, stackRef)
inStack := map[string]bool{}
for _, r := range exported.Resources { inStack[string(r.URN)] = true }
for name, urn := range refs {
if !inStack[urn] {
return fmt.Errorf("%s (%s) not in stack; regenerate resources file", name, urn)
}
} Prevention
- Regenerate the resources file per stack; never share it across stacks.
- Remove entries for destroyed resources.
- Diff resources-file URNs against a fresh stack export before each run.
When it happens
Trigger: Resources file maps a name to a URN that does not exist in the selected stack — wrong stack selected, resource deleted since the file was generated, or URN drift after renames.
Common situations: Switching stacks (dev vs prod) while reusing the same resources file; the file references a resource removed by a previous `pulumi destroy` or refresh.
Related errors
- key not found: %s
- checkpoint does not exist
- snapshot integrity failure; refusing to use it: %w
- An IO error occurred while writing the new snapshot file: %w
- %s: snapshot integrity failure; it was already written, but
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/d9c87aed47a71876.
Report an issue: GitHub.