> ## 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.

# local block

> Name a reusable computed value with the local block.

The `local` block names a reusable expression to avoid repetition across blocks. Equivalent to Terraform's `locals` block.

## Syntax

```hcl theme={null}
local "name" {
  value = expr
}
```

Only `value` is allowed. Any other attribute is a compile error. `for_each` is not supported on `local` blocks.

## Resolved Value

```hcl theme={null}
local "prefix" {
  value = "myapp-prod"
}

unit "aws_s3_bucket_v2" "assets" {
  bucket = local.prefix           # → "myapp-prod"
}

unit "aws_s3_bucket_v2" "logs" {
  bucket = "${local.prefix}-logs" # → "myapp-prod-logs"
}
```

Generated TypeScript:

```typescript theme={null}
// local "prefix"
const prefix = "myapp-prod";

const assets = new aws.s3.BucketV2("assets", { bucket: prefix });
const logs   = new aws.s3.BucketV2("logs",   { bucket: `${prefix}-logs` });
```

## `Pending&lt;T&gt;` Value

A `local` that holds a `Pending&lt;T&gt;` value stores the Pulumi `Output&lt;T&gt;` reference directly — no `.apply()` wrapper at declaration, it is passed through to consumers:

```hcl theme={null}
unit "aws_s3_bucket_v2" "primary" {
  bucket = "primary-store"
}

local "bucket_name" {
  value = ~unit.aws_s3_bucket_v2.primary.bucket
}

unit "aws_s3_bucket_v2" "replica" {
  bucket = local.bucket_name
}
```

Generated TypeScript:

```typescript theme={null}
const primary = new aws.s3.BucketV2("primary", { bucket: "primary-store" });

// local "bucket_name"
const bucket_name = primary.bucket;   // Output<string>

const replica = new aws.s3.BucketV2("replica", { bucket: bucket_name });
```

## Chained Locals

```hcl theme={null}
local "base" {
  value = "ubx"
}

local "full_name" {
  value = "${local.base}-platform"
}

unit "aws_s3_bucket_v2" "store" {
  bucket = local.full_name
}
```

## Error Cases

```
✗  stack.iac:5  local.missing is not declared in this file
```
