Type
Analyse
Published
Reading time
2 min read
Author
Lire en français
Lire en français →

DataTalks.Club: restored Terraform state changes destruction scope

Alexey Grigorev links local state, shared infrastructure and destruction. Review the plan and the separate recovery boundary.

Analysis of public sources

Read the article

Alexey Grigorev describes a Terraform state restoration bringing DataTalks.Club production infrastructure into a cleanup operation. His first-person account covers infrastructure shared with another project, a new computer without local state and transfer of an old archive. The agent used that state and started a destruction the user allowed to continue, believing it targeted duplicates.

This account includes human decisions and agent-assisted execution. It does not support describing the destruction as autonomous action without human involvement. The technical question is how loaded state, actual target objects and authorization were bound together.

Missing state → Duplicates created → Old state restored → Production selected. Scope follows the objects associated with the active state.

Scope follows the objects associated with the active state.

State identifies existing objects

Terraform state maps configuration addresses to remote objects. It is more than a command history. Restoring old state can reintroduce mappings to resources still serving production.

A fictional example illustrates the mismatch:

Terraform address: module.service.aws_db_instance.primary

Expected cleanup state:
  remote identifier = lab-copy

State restored from an archive:
  remote identifier = production-primary

The logical address stays the same; the target object changes. A task comment calling it a copy cannot change the identifier stored in state.

Verify the backend, workspace, state version and remote identifiers. The current directory’s name establishes none of these properties.

Review the changed situation

The account describes an initial attempt to create resources without the expected state, followed by interruption. Introducing an archive later changed the environment’s representation. A plan prepared before that change may no longer describe the next operation.

A proposed workflow binds the accepted plan to configuration revision, provider identity, backend, workspace and target-object list. Changes to those inputs require a new plan and scope review.

terraform plan -out can save a plan for later application. Protect the file because it may contain sensitive data. A stable filename does not establish that reviewers inspected its current contents; a digest can bind review to a specific artifact.

These are proposed operating controls. The incident’s public sources do not provide enough evidence to reconstruct every plan actually used.

Recovery depended on another system

The author reports losing associated automatic backups and later recovering through AWS support. This highlights dependencies between service deletion and copy retention. It guarantees no equivalent recovery route for another account.

Recovery planning must therefore remain independent of a successful support request. Identify the retained copy, its owner, its keys and its restore path in advance to measure what the team actually controls.

Terraform prevent_destroy can add a denial in certain configurations. It does not cover every deletion, including cases where resource configuration is removed. Cloud permissions and backup retention remain separate controls.

Review the actual targets

A destruction review should identify real objects, their environment and dependencies removed with them. A request to clean duplicates does not define that scope.

If old state arrives during a task, stop promoting the existing plan and inspect its mappings. Shared infrastructure requires reviewing the other project’s services too. Project names do not enforce provider-side isolation.

This analysis examines the account and Terraform documentation; we destroyed no infrastructure to verify it. Complete provider logs and the full authorization exchange remain unavailable in the cited public record.

Follow future rootzero publications

#rootzero

A question about your exposure?

Write to us. Someone from the technical team will answer, with sources.