Claude Code was granted permissions to manage AWS, after which the AI completely deleted two websites and their databases

Claude Code was granted permissions to manage AWS, after which the AI completely deleted two websites and their databases

48 software

Short news summary

Alexey Grigoryev is a developer who moved his site to Amazon Web Services (AWS). He used Terraform for infrastructure management and relied on Anthropic’s Claude Code agent. The agent’s error was not the cause of the incident: it stemmed from human factors.

What happened
Step Action Result 1 Alexey decided to combine two resources (the site and another service) into a single cloud infrastructure. He reduced the number of configurations but increased the risk of errors. 2 He chose Terraform for automation: creating/deleting servers, networks, load balancers, and databases. The Terraform plan included all necessary resources. 3 Alexey asked Claude Code to apply the plan but did not upload the state file describing the current configuration. The AI executed part of the command – it created a container for the site, but the user stopped the process halfway through. 4 Because there was no state, resources began to duplicate. Alexey decided to delete the duplicates and then uploaded the state file. He assumed that the agent would continue removing excess objects and open the state for proper configuration. 5 Claude Code executed `terraform destroy` according to the state file. The file specified an already existing database in AWS. Both sites and their data (2.5 years of records + snapshots) were deleted.

Consequences
- Loss of the entire database with a 2.5‑year history.
- Need to contact Amazon support to recover the data.

Within a day, AWS support restored all required objects.

What Alexey did after the incident
1. Periodic checks – set up regular monitoring of the database state.
2. Protection against deletion – enabled protection mechanisms in Terraform and in AWS settings.
3. Storing the state file – moved it to a secure S3 bucket instead of a local disk.
4. Independent deletion management – now all resource destruction operations are performed by the developer himself, not by an AI agent.

Conclusion
The incident was caused by human errors (the state file was not uploaded and misunderstandings about managing duplicate resources), not by shortcomings of Claude Code. Alexey took measures to minimize future risks and abandoned full dependence on AI when working with Terraform.

Comments (0)

Share your thoughts — please be polite and stay on topic.

No comments yet. Leave a comment — share your opinion!

To leave a comment, please log in.

Log in to comment