Skip to main content
The moved block renames a resource in Pulumi state. It compiles to aliases: ["old_name"] in the target unit’s Pulumi resource options.

Syntax

moved {
  from = unit.type.old_name
  to   = unit.type.new_name
}
No labels. Body contains exactly from and to — both plain block references (no ~ prefix). The moved block emits no TypeScript of its own.

Example

unit "aws_s3_bucket_v2" "new_assets" { bucket = "my-assets" }

moved {
  from = unit.aws_s3_bucket_v2.old_assets
  to   = unit.aws_s3_bucket_v2.new_assets
}
Generated TypeScript:
const new_assets = new aws.s3.BucketV2("new_assets", {
    bucket: "my-assets",
}, { aliases: ["old_assets"] });
On next ubx apply, Pulumi locates the existing state entry under "old_assets" and moves it to "new_assets" without destroying and recreating the resource.

Combined with lifecycle

unit "aws_s3_bucket_v2" "new_logs" {
  bucket    = "logs"
  lifecycle { prevent_destroy = true }
}

moved {
  from = unit.aws_s3_bucket_v2.old_logs
  to   = unit.aws_s3_bucket_v2.new_logs
}
const new_logs = new aws.s3.BucketV2("new_logs", {
    bucket: "logs",
}, { retainOnDelete: true, aliases: ["old_logs"] });

Multiple moved Blocks

moved { from = unit.aws_s3_bucket_v2.old_a; to = unit.aws_s3_bucket_v2.bucket_a }
moved { from = unit.aws_s3_bucket_v2.old_b; to = unit.aws_s3_bucket_v2.bucket_b }

Constraints

  • v1: only unit blocks can be source or target
  • from and to must reference the same resource type
  • The to block must be declared in the same file
  • A resource may only be the to target of one moved block