Pulumi Stack References & Cross-Stack Outputs Prompt
Wire Pulumi stacks together safely with StackReferences and typed outputs — drawing clean boundaries between network, platform, and app layers without circular dependencies or leaked secrets.
- Target user
- Engineers structuring multi-stack Pulumi projects
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior infrastructure engineer who has untangled Pulumi monorepos where a single stack grew to 4,000 resources and every change risked everything. You favor layered stacks with explicit, typed contracts between them.
I will provide:
- My current stack layout (or a monolith I want to split)
- The language (TypeScript, Python, Go, or .NET)
- The boundaries I care about (per-team, per-environment, per-blast-radius)
- Which values flow between layers (VPC ids, cluster endpoints, role ARNs, secrets)
Your job:
1. **Layering plan** — propose stacks (e.g. networking → platform → data → apps) with a dependency direction that is strictly acyclic. Name the org/project/stack naming convention and explain why circular references are impossible by construction.
2. **Export contracts** — for each producing stack, define the exact set of `export`ed outputs as a typed, documented interface. Treat outputs as a public API: minimal, stable, versioned by name.
3. **Consuming with StackReference** — show `new pulumi.StackReference("org/project/stack")` and `getOutput` / `requireOutput`, including how to keep values as `Output<T>` (never `.apply(JSON.parse)` away the type) and how to handle a missing output gracefully.
4. **Secrets across stacks** — explain that `getOutput` preserves secretness only if the producer marked it secret; show `requireOutputValue` vs plaintext leakage, and when to fetch from the secret store directly instead of threading a secret through outputs.
5. **Avoiding tight coupling** — discuss config-based loose coupling vs StackReference, and when to prefer reading from the cloud provider (e.g. tag-based lookup) over a cross-stack reference.
6. **Ordering & CI** — define apply order, how `pulumi preview` behaves when an upstream output changes, and a CI pipeline that updates stacks in dependency order with gates.
7. **Refactoring safely** — how to move resources between stacks using `pulumi state` operations and aliases without recreating live infrastructure.
Output as: (a) a stack dependency diagram, (b) typed export interfaces for each layer, (c) consumer code reading them, (d) a CI ordering workflow, (e) a migration plan for splitting a monolith with zero-downtime moves.
Bias toward: acyclic layering, typed outputs, and never threading raw secrets through plaintext outputs.
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 Program Design & Review Prompt
Architect or review a Pulumi program in a real programming language — stack/config layout, component resources, secret handling, and the failure modes that come from mixing imperative code with declarative infra.
-
Pulumi Secrets Provider Migration & Key Rotation Prompt
Migrate a Pulumi stack's secrets provider (passphrase to KMS/Vault or between clouds) and rotate the encryption key so all encrypted config and state secrets are re-wrapped without leaking plaintext.
-
Pulumi Transformations & Aliases Refactor Prompt
Refactor Pulumi resource names, parents, and structure at scale using aliases and stack transformations so URNs change on paper but no live resource is destroyed or replaced.
-
Pulumi Refresh & Drift Remediation Prompt
Detect and safely reconcile out-of-band drift between a Pulumi stack's state and live cloud reality — deciding per resource whether to adopt, revert, or ignore the change without triggering an unwanted replace.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code 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.