> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# output block

> Export stack values with the output block.

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

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

## Example

```hcl theme={null}
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"
}
```

```bash theme={null}
ubx output
# db_endpoint  =  "db.xxxx.eu-west-1.rds.amazonaws.com"
```

## sensitive = true

Wrapped in `pulumi.secret()` — shown as `[sensitive]` in terminal output:

```hcl theme={null}
output "db_password" {
  value     = ~unit.aws_rds_instance.db.password
  sensitive = true
}
```

```bash theme={null}
ubx output
# db_endpoint  =  "db.xxxx.eu-west-1.rds.amazonaws.com"
# db_password  =  [sensitive]
```

## depends\_on

```hcl theme={null}
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

```hcl theme={null}
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

```typescript theme={null}
// 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

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

unit "aws_subnet" "app" {
  vpc_id = ~@platform.vpc_id
}
```

See [`remote`](/v1/language/remote) for cross-stack reference syntax.
