Skip to main content
Large infrastructure projects split resources across multiple stacks. ubx’s remote block and ~@ syntax make cross-stack output wiring first-class.

Pattern

networking stack         →  exports: vpc_id, vpc_cidr

eks stack               →  consumes: vpc_id; exports: cluster_endpoint

apps stack              →  consumes: cluster_endpoint

Declaring a Remote Reference

# apps/stack.iac

remote "networking" {
  source = "github.com/myorg/platform//stacks/networking"
  stack  = "${input.env}"
}

Consuming Remote Outputs

Use ~@name.output syntax:
unit "aws_subnet" "app" {
  vpc_id     = ~@networking.vpc_id      # Pending<string>
  cidr_block = cidrsubnet(~@networking.vpc_cidr, 8, 1)
}
Cross-stack references are always Pending&lt;T&gt;.

The Remote Stack Must Export

The referenced stack must have a matching output block:
# networking/stack.iac

output "vpc_id" {
  value       = ~unit.aws_vpc.main.id
  description = "VPC ID for downstream stacks"
}

output "vpc_cidr" {
  value = ~unit.aws_vpc.main.cidr_block
}

Stack References in Generated TypeScript

const networking = new pulumi.StackReference(
  `myorg/networking/${env}`
);

const app = new aws.ec2.Subnet("app", {
    vpcId: networking.getOutput("vpc_id"),
});

Interface Contracts

Use interface blocks to enforce that a stack exports required outputs:
interface "networking_contract" {
  output "vpc_id" {
    type        = "string"
    description = "Required by downstream stacks"
  }
}
ubx validate fails if the output is missing.