kl rollback and kl state
These are the repair-oriented commands.
They are powerful, and they are intentionally more explicit than the happy-path plan/apply workflow.
kl rollback
kl rollback replays an old state version, or one historical resource address, as a new write.
It is dry-run by default.
Whole-state rollback example
kl rollback big-state --to=@2
This previews what would happen if you restored the state from two versions back.
To actually perform it:
kl rollback big-state --to=@2 --apply --yes
Resource rollback example
kl rollback resource big-state --address time_sleep.slow_a --to @1
Use this when one address needs repair but a whole-state rewind would be too broad.
Important warning
kl rollback rewinds KiloLock’s state bookkeeping. It does not roll back cloud resources by itself.
That is why preview-first behavior matters.
kl state rm
kl state rm removes one exact address from state.
In state-engine mode it is preview-first. Otherwise it falls back to Terraform compatibility mode.
Example
KL_PROTOCOL=state-engine kl state rm big-state --address time_sleep.slow_b
To actually write:
KL_PROTOCOL=state-engine kl state rm big-state --address time_sleep.slow_b --apply --yes
Use it when:
- state contains an address that should no longer be tracked
- you want exact-address operator repair
kl state mv
kl state mv moves one exact address to another.
Example
KL_PROTOCOL=state-engine kl state mv big-state \
--from time_sleep.slow_a \
--to module.demo.time_sleep.slow_a
To actually write:
KL_PROTOCOL=state-engine kl state mv big-state \
--from time_sleep.slow_a \
--to module.demo.time_sleep.slow_a \
--apply --yes
Use it when:
- an address rename happened
- a resource moved under a module path
- you need an exact-address repair without broader mutation
Suggested repair workflow
kl query history big-state --address time_sleep.slow_a
kl rollback resource big-state --address time_sleep.slow_a --to @1
terraform plan
Or for exact-address maintenance:
KL_PROTOCOL=state-engine kl state mv big-state --from old.addr --to new.addr
terraform plan