Skip to content

How to understand a Pulumi (TypeScript) codebase

Pulumi describes infrastructure in general-purpose code. The program creates resource objects, and Pulumi works out dependencies from how outputs of one resource feed into inputs of another. Values that are only known after deployment are `Output`s, which is the key concept for reading the code.

How to tell it's Pulumi (TypeScript)

  • Pulumi.yaml and Pulumi.<stack>.yaml files
  • @pulumi/pulumi plus provider packages such as @pulumi/aws
  • Calls like new aws.s3.Bucket(...), pulumi.interpolate and .apply(...)

Where things usually live

Pulumi.yaml
Project name and runtime.
Pulumi.<stack>.yaml
Per-stack config values, including encrypted secrets.
index.ts
The program: resources and exported outputs.
components/
ComponentResource classes that group related resources.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. index.ts and its exports
  2. Stack config files, to see how environments differ

How a request moves through the code

  1. 1pulumi up runs the program for the selected stack.
  2. 2Resources are registered; outputs passed as inputs create dependencies.
  3. 3Pulumi compares desired state with the stack's state and plans changes.
  4. 4Exported outputs are shown after deploy and can be read by other stacks.

Questions to ask about the repository

  • Which resources does this program create, grouped by component?
  • Which config values differ per stack?
  • Which outputs are exported, and who consumes them?

What trips people up

  • An Output is not a plain value; using it in a template string without interpolate or apply gives a placeholder.
  • Renaming a resource's logical name replaces it unless an alias is added.