pulumi/pulumi · error

open resources file: %w

Error message

open resources file: %w

What it means

readResourceReferences opens the JSON resources file passed to the command. If os.Open fails (missing path, no permissions), the OS error is wrapped as "open resources file: ...".

Source

Thrown at pkg/cmd/pulumi/do/do_resource_upsert.go:524

			"whose values are the URNs of existing resources in the stack, for example:\n"+
			"  {\n"+
			"    \"myBucket\": \"urn:pulumi:dev::my-project::aws:s3/bucket:Bucket::my-bucket\",\n"+
			"    \"myVpc\":    \"urn:pulumi:dev::my-project::aws:ec2/vpc:Vpc::my-vpc\"\n"+
			"  }\n"+
			"Identifiers for existing stack resources are auto-assigned; run `pulumi do show-resources`\n"+
			"to see them. Entries in this file take precedence over any auto-assigned identifier.")
	cmd.Flags().BoolVar(yes, "yes", false,
		"Automatically approve and perform the operation without a confirmation prompt")
	addInputFlags(cmd, "input", inputs)
}

func readResourceReferences(path string) (map[string]string, error) {
	if path == "" {
		return nil, nil
	}
	f, err := os.Open(path)
	if err != nil {
		return nil, fmt.Errorf("open resources file: %w", err)
	}
	defer contract.IgnoreClose(f)

	var refs map[string]string
	if err := json.NewDecoder(f).Decode(&refs); err != nil {
		return nil, fmt.Errorf("parse resources file: %w", err)
	}
	for name, rawURN := range refs {
		if name == "" {
			return nil, errors.New("resources file contains an empty resource name")
		}
		urn, err := resource.ParseURN(rawURN)
		if err != nil {
			return nil, fmt.Errorf("resources file contains invalid URN for %q: %w", name, err)
		}
		refs[name] = string(urn)
	}
	return refs, nil

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Check the path exists and is readable: `ls -l <path>` or `cat <path>`.
  2. Use an absolute path or run from the correct working directory.
  3. Ensure the upstream step (e.g. resource upsert) that writes the resources file completed successfully before invoking the update/patch.

Example fix

// before
pulumi resource update --resources-file ./resorces.json
// after
pulumi resource update --resources-file ./resources.json
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(path)
if err != nil || info.IsDir() {
  return fmt.Errorf("resources file %q missing or not a regular file", path)
}

Prevention

When it happens

Trigger: Passing a --resources-file path that does not exist, a directory path, or a file the process cannot read to runStatefulSnippetUpdate or runStatefulSnippetPatch.

Common situations: Typoed file path, running from a different working directory with a relative path, a previous step that was supposed to generate the resources file failed silently, or restrictive file permissions.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/3af6baf2cfd1200c. Report an issue: GitHub.