pulumi/pulumi · error
unknown resource %v
Error message
unknown resource %v
What it means
The pulumi:pulumi:getResource builtin invoke looks up a resource's registered outputs by URN among resources created (news) or read (reads) during the current deployment. If the given URN was not registered in either map, the resource is unknown to the engine and this error is returned.
Source
Thrown at pkg/resource/deploy/builtins.go:454
return property.NewMap(map[string]property.Value{
"name": name,
"outputs": property.New(outputs),
}), nil
}
func (p *builtinProvider) getResource(inputs property.Map) (property.Map, error) {
urnInput, ok := inputs.GetOk("urn")
contract.Assertf(ok, "missing required property 'urn'")
contract.Assertf(urnInput.IsString(), "expected 'urn' to be a string")
// When looking up a resource to hydrate it, we'll first check for new states produced by resource registrations. If
// we fail to find a match there, we'll look for states that have been read.
urn := resource.URN(urnInput.AsString())
state, ok := p.news.Load(urn)
if !ok {
state, ok = p.reads.Load(urn)
if !ok {
return property.Map{}, fmt.Errorf("unknown resource %v", urnInput.AsString())
}
}
// Take the state lock so we can safely read the Outputs.
state.Lock.Lock()
defer state.Lock.Unlock()
return property.NewMap(map[string]property.Value{
"urn": urnInput,
"id": property.New(string(state.ID)),
"provider": property.New(state.Provider),
"state": property.New(resource.FromResourcePropertyMap(state.Outputs)),
}), nil
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Pass the URN of a resource created in the current deployment (ideally derive it from the resource object, not a string literal)
- Verify the URN string exactly matches type:name including stack/project prefixes
- Ensure the getResource call happens after the target resource is registered (not in a pre-deploy step)
- If the resource is from another stack, use getStackOutputs/getStackResourceOutputs instead
Example fix
// before
pulumi.getResource({ urn: "urn:pulumi:dev::proj::aws:s3/bucket:Bucket::wrong-name" })
// after: use the actual resource's URN
const res = new aws.s3.Bucket("b")
// after creation: invoke with res.urn Defensive patterns
Strategy: validation
Validate before calling
// go: ensure the URN belongs to this deployment before lookup
if !strings.HasPrefix(urn.String(), d.baseStackURNPrefix) { return fmt.Errorf("URN %s is not from this stack", urn) } Type guard
func isKnownURN(urn resource.URN, news, reads *sync.Map) bool { _, ok1 := news.Load(urn); _, ok2 := reads.Load(urn); return ok1 || ok2 } Try / catch
state, err := lookupRegisteredURN(urn)
if err != nil && strings.Contains(err.Error(), "unknown resource") { /* register or use getStackResourceOutputs */ } Prevention
- Only query URNs produced during the current update
- Don't hardcode URNs; capture them from resource creation
- Use cross-stack helpers for resources in other stacks
When it happens
Trigger: Invoking pulumi:pulumi:getResource with a urn argument that does not match any resource created or read in the current update — e.g. a stale/typo'd URN, or querying before the resource has been registered.
Common situations: Programs calling pulumi.getResource with a hand-built URN string; referencing a resource from a different stack/update; the target resource was deleted or renamed; runtime ordering where getResource runs before the resource exists.
Related errors
- unrecognized function name: '%v'
- no backend client is available
- invalid dependsOn URN %q: %w
- failed to normalize URN references: %w
- failed to normalize URN references: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/23f926e31c66376d.
Report an issue: GitHub.