Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Pulumi Difficulty: Advanced ClaudeChatGPT

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

More Pulumi prompts & error guides

Browse every Pulumi prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.