feat(scripts): snapshot opentofu state before and after tofu apply #472

Sammanfogat
supernaut sammanfogade 5 incheckningar från feat/tofu-apply-snapshot in i main 2026-09-08 23:11:26 +00:00
Ägare

What

OpenTofu state is local and encrypted with no remote backend, so a bad apply had no rollback point. scripts/tofu-apply.sh wraps tofu apply:

  • Snapshots terraform.tfstate, its .backup and terraform.tfvars into opentofu/state-snapshots/<utc>-<sha>/ before the apply and again (-post) after it, exiting with apply's code.
  • Keeps the newest 20 snapshots.
  • Refuses to run without the state passphrase.
  • --restore <dir> replays a snapshot after a typed confirmation and refuses on uncommitted opentofu/*.tofu changes.
  • --self-test exercises snapshot, prune and restore against a temp copy.

pnpm tofu:apply now runs the wrapper. opentofu/state-snapshots/ is gitignored. No production apply is involved; the snapshots stay on the operator machine (off-site copy is #470).

Checks

scripts/tofu-apply.sh --self-test (6/6), shellcheck on the script.

## What OpenTofu state is local and encrypted with no remote backend, so a bad apply had no rollback point. `scripts/tofu-apply.sh` wraps `tofu apply`: - Snapshots `terraform.tfstate`, its `.backup` and `terraform.tfvars` into `opentofu/state-snapshots/<utc>-<sha>/` before the apply and again (`-post`) after it, exiting with apply's code. - Keeps the newest 20 snapshots. - Refuses to run without the state passphrase. - `--restore <dir>` replays a snapshot after a typed confirmation and refuses on uncommitted `opentofu/*.tofu` changes. - `--self-test` exercises snapshot, prune and restore against a temp copy. `pnpm tofu:apply` now runs the wrapper. `opentofu/state-snapshots/` is gitignored. No production apply is involved; the snapshots stay on the operator machine (off-site copy is #470). ## Checks `scripts/tofu-apply.sh --self-test` (6/6), shellcheck on the script.
supernaut lade till 5 incheckningar 2026-09-08 23:08:44 +00:00
supernaut sammanfogade incheckning 9d1968180e till main 2026-09-08 23:11:26 +00:00
supernaut tog bort grenen feat/tofu-apply-snapshot 2026-09-08 23:11:26 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra!472
Ingen beskrivning angiven.