Skip to main content
The local block names a reusable expression to avoid repetition across blocks. Equivalent to Terraform’s locals block.

Syntax

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

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:
// 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<T> Value

A local that holds a Pending<T> value stores the Pulumi Output<T> reference directly — no .apply() wrapper at declaration, it is passed through to consumers:
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:
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

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