Skip to content

In review · not yet published

6 min readLaunchapp

Terraform destroy, and the backups that went with it

An agent ran terraform destroy on a live course platform and the automated snapshots went too. The founder's postmortem shows which controls matter.

On February 26, 2026, the infrastructure behind the DataTalks.Club course platform was destroyed by a single Terraform command, run by an AI coding agent while its operator watched. The database, the network around it and every automated snapshot were gone within an hour of the first mistake.

We know the details because the founder, Alexey Grigorev, published a full postmortem, "How I Dropped Our Production Database and Now Pay 10% More for AWS", and later talked it through in an interview with Rootly. The account is unusually candid. It includes the sentence "This incident was my fault." That candour is why this is one of the most useful incident reports of the year, and we are grateful for it.

What happened

The sequence, as the postmortem tells it:

  1. Grigorev was working from a new computer and ran Terraform without the state file, which was still on the old machine. Terraform, knowing nothing about the existing infrastructure, created duplicates.
  2. The goal became removing only the duplicates. Cleanup started through the AWS CLI, with Claude Code running the commands.
  3. To give the agent context, Grigorev made an archive of the old Terraform folder, which contained the real state, and pointed the agent at it. The agent unpacked it. In the postmortem's words, "It replaced my current state file with an older one".
  4. From that moment Terraform's picture of "what this project owns" was the live platform. The agent proposed switching approach. Grigorev quotes its reasoning: destroying the resources through Terraform "would be cleaner and simpler than through AWS CLI."
  5. The agent ran terraform destroy with auto-approve. Grigorev saw the command and did not stop it.

The result: "The database, VPC, ECS cluster, load balancers, and the bastion host were gone." And then the line that turns an outage into a crisis: "all automated snapshots were deleted too."

The platform held 2.5 years of course submissions: homework, projects and leaderboard entries.

PL. 07How one command reached the backupsCause chain · read left to right
  1. Link 01

    Terraform state lived on one laptop

    Guardrail

    Remote state, locked and versioned

  2. Link 02

    An agent ran plan, apply and destroy itself

    Guardrail

    A person reviews every plan and runs destructive commands

  3. Link 03

    The credentials could delete production

    Guardrail

    Separate credentials per environment

  4. Link 04

    Nothing protected the database from deletion

    Guardrail

    Deletion protection on the database

  5. Link 05

    Snapshots were deleted with the database

    Guardrail

    Backups the same credentials cannot delete

Each link is a condition that had to hold for the damage to happen. The line beneath it is the control that breaks that link.

Why it happened, in engineering terms

It is tempting to read this as "the AI went rogue". The postmortem does not support that reading, and neither do we. The agent did something locally reasonable with the information it had: given a state file that listed these resources, destroy is the tidy way to remove them. The state file was wrong about what was a duplicate. That is a data problem, not a reasoning problem.

Five conditions had to hold for the command to do this much damage.

The state was a file on a laptop. Terraform state is the record of what your infrastructure is. Kept locally, it can be missing, stale or swapped for an older copy, and all three happened here in one evening.

The agent executed, not just proposed. Grigorev writes that instead of reading the plan, "I let Claude Code run terraform plan and then terraform apply." An agent that can run apply can run destroy. The two are the same permission.

The credentials reached production. There was one AWS account. A cleanup task for duplicates ran with the authority to remove the real thing.

Nothing made the database hard to delete. In the postmortem's words: "The database was too easy to delete."

The backups shared the database's fate. Automated snapshots belong to the database instance. Delete the instance through the same path and, without a final snapshot or a separate copy, they go with it.

Remove any one of these and the story is a bad evening. All five together is how a course platform disappears at 11 PM.

What it cost

Less than it could have. AWS support, in Grigorev's telling, "found a snapshot on their end that I couldn't see in my console", and "Exactly 24 hours after the database had been deleted, AWS restored the snapshot." The restored table of course answers alone held 1,943,200 rows.

So the cost was a day of downtime for a live platform, a night of real fear, and a standing bill: getting that help meant upgrading to a paid AWS support tier, which the title of the postmortem records as paying 10% more.

It is worth being exact about one thing. The recovery depended on a snapshot the customer could not see or control. That is good fortune and good support, and it is not a backup strategy.

The practice that stops it

Grigorev's own list of changes is the best guide, because it is what someone chose to do the morning after:

  • Backups that Terraform does not manage. If the tool that can destroy the database also owns the backups, one command reaches both.
  • A restore test, every day. The postmortem describes a scheduled job that restores a backup and checks it. A backup that has never been restored is a hope.
  • Deletion protection at two levels, so that removing the database takes more than one decision.
  • Versioning on the backup storage, so a deletion there is recoverable too.
  • Terraform state moved to remote storage, where it cannot be left on an old machine.
  • A change in how the agent is used. In Grigorev's words: "Agents no longer execute commands", "Every plan is reviewed manually", and "Every destructive action is run by me".

We would add the general form of those rules.

Treat backups as a separate system with a separate key. The test is simple: is there any single credential that can delete both the data and every copy of it? If yes, that credential will eventually be used by a person in a hurry, a script with a bug, or an agent with the wrong state file. Put the copies in a different account, or behind a retention lock, so the answer is no.

Separate "propose" from "do". An agent reading a Terraform plan and explaining it is useful and safe. An agent applying it is a different capability, and for production it should pass through a person. The plan is the artefact a human reviews; the apply is a step a human triggers.

Give each environment its own credentials. A task about duplicates in a scratch environment should hold a key that cannot name production resources at all. The postmortem notes that a separate AWS account for development is still under consideration, which is an honest reminder that these changes take time even after an incident.

A backup that can be deleted by the same key as the data is a second copy of the same risk.

How we handle this

We run our own delivery on Animus, the orchestrator we built, and two of its design decisions are aimed squarely at this failure.

First, destructive operations are built to be previewed and confirmed. As we describe in our post on MCP server design, destructive tools take a dry-run flag that returns what would happen, and cancelling a workflow requires a confirmation value equal to the workflow's id, which a model cannot produce by guessing "true".

Second, the step where a person says yes is part of the workflow, not a habit. A workflow can include a manual phase that pauses until someone approves it, and an agent's request for approval fails closed if nobody answers. The tools for answering approvals are on a surface agents do not have, so an agent cannot approve its own request. People and agents on one board covers how that works day to day.

None of that makes us immune to a stale state file. It means that when an agent proposes something destructive, the design puts a person between the proposal and the command.

What we built

The work behind this post: Animus, whose workflows carry the review and approval gates described above, and the worktree manager MCP server that keeps agents in isolated workspaces. The cards below link to both.

Proof

The work behind this post

  • Built

    Animus

    Open-source orchestrator with a Rust core that runs teams of AI coding agents in parallel. Its whole control surface is exposed over MCP.

    commits on main since Feb 2026
    1,700+
    commits on main since Feb 2026
    View source
  • Built

    Worktree manager MCP server

    An MCP server with 47 tools that lets AI agents create, run and clean up isolated git worktrees, so many agents can work on one codebase in parallel.

    agent-facing tools
    47
    agent-facing tools

Founder-led

Building something like this? A founder will reply personally.

Scope a project