media_files becomes media_store when the team reorganises. A security group called app needs to become api when a second app tier is added. In plain Pulumi, renaming a resource means deleting the old one and creating a new one — which for a production S3 bucket with data, or an RDS instance with a live database, or any stateful resource, is simply not acceptable. The moved block tells Pulumi that the old state key (the old label) maps to the new unit block (the new label), so the rename is recorded as a state operation rather than a destroy-and-recreate. No downtime. No data loss. Just a new name in state.
What you’ll learn
- How
movedrenames a resource in Pulumi state without destroying it - The
from/tosyntax and what each references - When to remove the
movedblock after applying
Why this matters
Without
moved, renaming a unit block label causes Pulumi to destroy the old resource and create a new one. For stateful resources — databases, storage buckets, load balancers — this is destructive. moved makes refactoring safe.The source code
How it works
ubx compiles moved to a Pulumi alias
The
moved block compiles to a aliases option on the to resource’s Pulumi constructor. The alias is the full Pulumi URN of the old resource (derived from the from reference). Pulumi uses aliases to match existing state entries to new resource declarations.Pulumi recognises the alias and skips destroy
At apply time, Pulumi looks up the old URN in state, finds a matching alias on the new resource, and records the rename as a state update rather than a destroy-and-create. The cloud resource is unchanged — only the state entry is updated.
What ubx generates
Common mistakes
Run it
What you learned
moved renames a resource in Pulumi state without destroying or recreating the cloud resourcefrom references the old label (the block no longer needs to exist); to references the new unit blockRemove the
moved block after the first successful applyNext steps
data source lookup
Query existing cloud resources without managing them
moved block reference
Full moved block syntax
Full runnable example: github.com/ubiquex/ubx-examples/32-moved-block-resource-rename

