Implement a Pulumi Stack Reference pattern where an infrastructure stack exports VPC and subnet IDs consumed by an application stack in a different project

domain: Pulumi · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. In the infrastructure Pulumi program, export the VPC ID and private subnet IDs as stack outputs using pulumi.export('vpcId', vpc.id) and pulumi.export('privateSubnetIds', pulumi.all(subnets).apply(ids => ids))
  2. In the application Pulumi program, declare a StackReference pointing to the infrastructure stack using new pulumi.StackReference('org/infra-project/prod') and assign it to a constant
  3. Retrieve the exported values using stackRef.getOutput('vpcId') and stackRef.requireOutput('privateSubnetIds'); use requireOutput for values that must exist to fail fast if the infrastructure stack has not been applied
  4. Pass the retrieved values as inputs to application resources; Pulumi will automatically track the cross-stack dependency and the application stack's up will fail if the referenced infrastructure stack is not in a ready state
  5. In CI, enforce that the infrastructure stack apply completes and succeeds before the application stack pipeline is triggered, using a pipeline dependency or artifact-passing mechanism to sequence the applies
  6. Add a pulumi policy in the application stack that reads the StackReference outputs and validates the VPC CIDR falls within the approved range before allowing resources to be created, using Pulumi CrossGuard

Known gotchas

Related routes

Implement Pulumi stack references to share infrastructure outputs between a network stack and an application stack in separate Pulumi projects
pulumi.com · 5 steps · unrated
Configure Pulumi to provision infrastructure using Python and manage stack secrets with the passphrase secrets provider instead of Pulumi Cloud
www.pulumi.com · 6 steps · unrated
Use the Pulumi Automation API in Python to programmatically create and destroy ephemeral stacks with inline programs for integration test environments
pulumi.com · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans