Skip to main content
The output block declares values that are exported from a stack. Outputs become pulumi.export() calls in the generated Python program. Other stacks can consume them via @stackName.outputName cross-stack references.

Syntax

output "name" {
    field_name = expr
    field_name = expr
}

Example

output "networking" {
    vpc_id     = vpc.id
    subnet_ids = subnets.id
}
Generated Python:
# ── Outputs ───────────────────────────────────────────────────────────────────
pulumi.export("vpc_id", vpc.id)
pulumi.export("subnet_ids", [r.id for r in subnets])

Referencing outputs from other stacks

Once a stack exports an output, a sibling stack can reference it with @stackName.outputName:
// cluster/stack.xcl
stack "cluster" {
    eks = aws.eks.Cluster {
        vpc_id     = @networking.vpc_id
        subnet_ids = @networking.subnet_ids
    }
}
See Multi-stack workspaces for how sibling discovery works.

What expressions are valid

Output field values can reference:
  • Resource outputs: vpc.id, subnets.id
  • Input fields: input.vpc_cidr
  • Locals fields: locals.computed_value
  • Cross-stack refs: @otherStack.someOutput
  • Literals: "static", 42, true
The typechecker resolves all references. Undefined names produce an error:
output "s" {
    id = myresource.id  // error if "myresource" is not declared in a stack block
}

Duplicate field names

Output field names must be unique across all output blocks in the stack:
// file-a.xcl
output "a" { vpc_id = vpc.id }
// file-b.xcl
output "b" { vpc_id = vpc.id }  // error: "vpc_id" is already defined in file-a.xcl:2 - remove one, or rename

Multiple output blocks

A stack may have multiple output blocks (typically one per file). All field names share a flat namespace.