Skip to main content
The output block exports a value from the stack. Shown by ubx output and consumed by other stacks via cross-stack references. Equivalent to Terraform’s output block.

Syntax

output "name" {
  value       = expression
  description = "optional"
  sensitive   = false
  depends_on  = [unit.x.y]
  when        = condition
}

Example

unit "aws_rds_instance" "db" {
  engine         = "postgres"
  instance_class = "db.t3.micro"
}

output "db_endpoint" {
  value       = ~unit.aws_rds_instance.db.endpoint
  description = "RDS connection endpoint"
}
ubx output
# db_endpoint  =  "db.xxxx.eu-west-1.rds.amazonaws.com"

sensitive = true

Wrapped in pulumi.secret() — shown as [sensitive] in terminal output:
output "db_password" {
  value     = ~unit.aws_rds_instance.db.password
  sensitive = true
}
ubx output
# db_endpoint  =  "db.xxxx.eu-west-1.rds.amazonaws.com"
# db_password  =  [sensitive]

depends_on

output "bucket_url" {
  value      = ~unit.aws_s3_bucket_v2.assets.bucket
  depends_on = [unit.aws_iam_role.uploader]
}
Compiled to pulumi.all([assets.bucket, uploader]).apply(([v]) => v).

when

input "env" { default = "dev" }

output "replica_endpoint" {
  value = ~unit.aws_rds_instance.replica.endpoint
  when  = input.env == "prod"
}
When condition is false, output is pulumi.output(undefined).

Generated TypeScript

// output "db_endpoint"
export const db_endpoint = db.endpoint;

// sensitive = true
export const db_password = pulumi.secret(db.password);

// when
export const replica_endpoint = ((env === "prod"))
  ? replica.endpoint
  : pulumi.output(undefined);

Cross-Stack Consumption

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

unit "aws_subnet" "app" {
  vpc_id = ~@platform.vpc_id
}
See remote for cross-stack reference syntax.