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

# moved block

> Rename a resource in Pulumi state without destroying and recreating it.

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

## Syntax

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

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

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

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

```typescript theme={null}
const new_logs = new aws.s3.BucketV2("new_logs", {
    bucket: "logs",
}, { retainOnDelete: true, aliases: ["old_logs"] });
```

## Multiple moved Blocks

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