Pulumi Cross-Stack References & Outputs Prompt
Wire Pulumi stacks together with StackReferences and exported outputs so downstream stacks consume upstream infrastructure through a stable contract instead of hardcoded IDs or circular dependencies.
- Target user
- Engineers composing multi-stack Pulumi architectures
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior infrastructure engineer who designs multi-stack Pulumi architectures and has debugged more than one circular stack dependency at 2am. I will provide: - My current stack layout (e.g. network, data, app, edge) and language - Which stacks need values from which (VPC IDs, subnet IDs, cluster endpoints, secret ARNs) - Whether stacks live in one project or several, and one org or several - Any current coupling pain: brittle references, ordering problems, or hardcoded IDs Your job: 1. **Define the output contract** — for each producing stack, specify the minimal, stable set of `export`ed outputs it should publish (IDs, endpoints, ARNs) and treat that set as a public API other stacks depend on. 2. **Consume with StackReference** — show how a downstream stack reads upstream outputs via `StackReference`, including how to read secret outputs with `getOutput`/`requireOutputValue` and how to keep the referenced stack slug configurable rather than hardcoded. 3. **Dependency direction** — enforce a strict DAG. Show how to detect and break accidental cycles, and where to introduce a shared "foundation" stack instead of cross-referencing peer stacks. 4. **Typing & safety** — handle the `Output<T>` erosion at stack boundaries: validate and re-type consumed values so a missing or renamed output fails fast at preview, not mid-apply. 5. **Versioning the contract** — a policy for changing exported outputs: additive-safe changes vs breaking renames, and a deprecation path so consumers aren't broken by a rename. 6. **Testing the seam** — how to assert a producing stack still exports the expected keys, so a refactor can't silently drop an output a downstream stack needs. Output as: (a) the output contract per stack, (b) producer `export` snippets and consumer `StackReference` snippets in my language, (c) a dependency DAG (text diagram), (d) the output-versioning policy, (e) a contract test example. Bias toward: a small stable output surface, one-directional dependencies, and failing loudly when a referenced output is missing.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Pulumi Project & Stack Design Prompt
Lay out a Pulumi project and its stacks — one program, many environments — so config, state, and blast radius are cleanly separated instead of forked per environment.
-
Pulumi Config & Secrets with ESC Prompt
Design Pulumi configuration and secret handling across stacks — including Pulumi ESC environments — so config is DRY, secrets stay encrypted, and no plaintext credential ever lands in git.
-
Pulumi Component Resource Design Prompt
Design reusable Pulumi ComponentResources with typed inputs, clean outputs, and proper parenting so platform teams ship opinionated building blocks instead of copy-pasted resource soup.
-
Pulumi Automation API Programmatic Deployments Prompt
Design a programmatic deployment layer with the Pulumi Automation API — driving stacks from your own code or service — so you can build self-service infra, custom orchestration, and platform APIs without shelling out to the CLI.
More Pulumi prompts & error guides
Browse every Pulumi prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
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.