Pulumi Error: 'error parsing Pulumi.yaml' — Invalid YAML Program Fix
Fix Pulumi YAML 'error parsing Pulumi.yaml' / invalid YAML program: indentation, tabs, bad interpolation syntax, and malformed resources blocks in a YAML program.
- #pulumi
- #iac
- #troubleshooting
- #errors
Stuck on this Pulumi error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
Exact Error Message
error: error parsing Pulumi.yaml: could not unmarshal YAML:
yaml: line 14: did not find expected key
error: could not load Pulumi.yaml: invalid YAML program
You may also see yaml: line N: found character that cannot start any token (usually a tab), mapping values are not allowed in this context, or error: resource my-bucket: property "type" is required. All indicate the YAML program or project file could not be parsed or validated.
What It Means
Pulumi’s YAML runtime treats Pulumi.yaml itself as the program: the resources, variables, and outputs sections declare your infrastructure directly in YAML. Before Pulumi can plan anything, it has to parse that YAML and validate it against the program schema. “error parsing Pulumi.yaml” means the parser hit malformed YAML — bad indentation, a tab character, an unquoted special character — or the structure did not match what the schema expects (for example a resource missing its type).
This is a document-syntax or schema-shape problem, not a provider or credentials issue. The fix is to make the YAML both valid and well-formed for the Pulumi program schema.
Common Causes
- Inconsistent indentation or a tab character (YAML requires spaces).
- A value containing a special character (
:,{,@) left unquoted. - A resource entry missing the required
typekey, orpropertiesmisindented under it. - Broken interpolation syntax —
${...}references that are malformed or point at an undefined name. - A duplicate key in a mapping (two resources or two properties with the same name).
- A misplaced top-level key so
resources/outputsnest under the wrong parent.
Diagnostic Commands
Validate the raw YAML syntax independently of Pulumi:
python3 -c "import yaml,sys; yaml.safe_load(open('Pulumi.yaml'))"
Reveal hidden tabs and trailing whitespace that break parsing:
grep -nP "\t" Pulumi.yaml
cat -A Pulumi.yaml | head -n 40
Let Pulumi report the exact line and validation error:
pulumi preview
Confirm the runtime is actually yaml:
head -n 5 Pulumi.yaml
Step-by-Step Resolution
-
Read the reported line number.
did not find expected keyandmapping values are not allowedalmost always point at an indentation or missing-colon problem on or just above that line. -
Replace any tabs with spaces and make indentation consistent (two spaces per level is conventional):
sed -i 's/\t/ /g' Pulumi.yaml
- Quote values that contain special characters so the parser does not misread them:
variables:
connString: "host:5432,ssl:true" # colons must be quoted
- Give every resource a
typeand nestpropertiescorrectly. A valid resource block looks like this:
name: my-app
runtime: yaml
resources:
data-bucket:
type: aws:s3:Bucket
properties:
acl: private
outputs:
bucketName: ${data-bucket.id}
-
Fix interpolation references so
${...}names an actual resource or variable declared in the file, and remove duplicate keys. -
Re-validate and preview:
python3 -c "import yaml; yaml.safe_load(open('Pulumi.yaml'))" && pulumi preview
If a nested resources block is hard to structure, describe what you are building and let a prompt from the Pulumi prompt library generate a schema-correct YAML skeleton to compare against.
Prevention
- Use an editor with YAML linting (yamllint or an IDE plugin) so tabs and indentation errors surface as you type.
- Configure your editor to insert spaces, never tabs, and to show whitespace.
- Quote any string containing
:,{,},@, or a leading%/&/*. - Keep the resource schema handy: every resource needs
type, andpropertiesnests one level under it. - Run a
yaml.safe_load(oryamllint) check in CI beforepulumi previewso parse errors fail fast.
Related Errors
no Pulumi.yaml project file found— the file is missing or you are in the wrong directory, not a parse error.resource ...: property "type" is required— valid YAML but an incomplete resource block.unknown provider type— the YAML parsed but names atypeno installed provider supports.invalid config key— aconfig/variablesreference that does not resolve.
Frequently Asked Questions
Why does Pulumi parse Pulumi.yaml as a program? With runtime: yaml, the project file is the program — the resources and outputs sections declare infrastructure directly, so it must parse and validate before planning.
What causes found character that cannot start any token? Almost always a literal tab character; YAML forbids tabs for indentation, so replace them with spaces.
How do I reference one resource from another? Use ${resourceName.property} interpolation (for example ${data-bucket.id}), and make sure the referenced name is declared in the same file.
Is a YAML program less capable than TypeScript or Go? It is simpler and great for straightforward stacks, but you can convert to a full language later with pulumi convert. For more YAML program guidance, see the Pulumi guides.
Fixed it? Get 500 Pulumi & 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.
Did this fix your issue?
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.