Terraform Blast Radius
A rename plans one line of destroy, and the apply runs it.
What Is Terraform Blast Radius?
A monolithic Terraform stack holds prod and dev together, one role can apply to all of it, and the production database has no protection against being destroyed. You'll rename a resource, watch the plan grow a single line of destroy, and the apply replace a live database empty. Then you'll add prevent_destroy and deletion protection so a replacement errors instead of running, use a moved block so a rename stays a move, and split prod into its own state and role so one change can no longer reach everything.
What You'll Learn in Terraform Blast Radius
- Terraform binds a resource to its name, so renaming it with no moved block plans a destroy and recreate.
- A monolithic stack with one apply role makes every change account-wide, so one mistake or credential can reach production.
- prevent_destroy and provider deletion protection turn a silent replacement of a stateful resource into a loud failure at plan time.
- Splitting state per environment and component, with a role per stack, limits how far any one change can spread.
Terraform Blast Radius — Training Steps
-
One state holds everything
Bob has a leaked credential for Vandrith's CI deploy role. He does not need an exploit. He needs a change that looks routine, because one state file and one role manage the whole account. Vandrith runs a telehealth appointments platform. Its Terraform holds prod and dev in a single stack.
-
Open the stack
The production database is the richest target. Bob opens the file that declares it.
-
Nothing refuses a replacement
The resource name is only a label in the state. Terraform ties the real database to that label, so changing it makes Terraform believe the old database is gone. Nothing in this file stops that.
-
A change that reads as cleanup
Bob renames the resource from main to primary. In a pull request it reads as tidying. In the state it means the database called main no longer exists.
-
The destroy line in the plan
The plan is where this would be caught, if anyone read it. The destroy sits in a diff nobody scrolls through.
-
The apply runs it
The pipeline applies on merge. The database called main is destroyed, and a brand-new empty one takes its name.
-
What is left
Bob points a client at the database to see the damage. The table the platform runs on is still there, with nothing in it.
-
How a rename did that
-
The platform is empty
Appointments are gone and the platform is serving an empty database. The on-call incident points at a single merged pull request.
-
Open the database stack
Alice opens the stack that was applied. The rename has been reverted and the database restored from backup under main, but nothing stops it being destroyed again, and it still shares a state with everything else.
Security Framework Coverage
CWE
- CWE-693 Protection Mechanism Failure
CIS Controls
- CIS 4 Secure Configuration of Enterprise Assets and Software
- CIS 11 Data Recovery
NIST CSF
- PR.AT-02 Individuals in specialized roles are provided with awareness and training so that they possess the knowledge and skills to perform relevant tasks with cybersecurity risks in mind
- PR.PS Platform Security
- PR.DS Data Security
- RC.RP Incident Recovery Plan Execution
NICE Framework
- DD-WRL-004 Secure Systems Development
- IO-WRL-005 Systems Administration