Terraform Plan Explainer
Analyze Terraform plans for security risks, blast radius, and dependencies. Reduce production incidents by understanding infrastructure changes before applying them.
Open the full Terraform Plan Explainer tool →Blast radius in Terraform is the potential scope of a change: resources Terraform directly modifies, plus dependent resources and services that may be affected. Read the plan's action symbols (+ create, ~ update, - delete, -/+ replace), then inspect Terraform-managed dependencies with terraform graph and the configuration. terraform state list only lists managed resources; inspect other states and external consumers separately. A replacement or deletion of a stateful or networking resource (VPC, subnet, RDS, security group) can cascade through dependent systems. A smaller scope may allow an in-place update; a wider scope may require a migration plan, a backup, and a maintenance window.
The diagrams below illustrate possible dependency effects and a scoring rubric for organizing review. The four scenarios use illustrative plan excerpts, with simplified comments and hypothetical impacts; they are not captured Terraform output. Check the actual plan and configuration before choosing a migration approach.
You've been working on infrastructure changes for hours. Your Terraform plan shows several resources will be modified. You type terraform apply and your finger hovers over Enter. A voice in your head asks: "What could possibly go wrong?"
This moment—the gap between terraform plan and terraform apply—is where production incidents are born. A misunderstood change. A missed dependency. An unexpected replacement. And suddenly, your production database is gone, your VPC routing is broken, or your S3 bucket is public.
Understanding blast radius, risk assessment, and how to read Terraform plans thoroughly is essential for any team managing infrastructure as code. Let's learn how to make that moment before hitting Enter a confident one, not a terrifying one.
GitHub Repository: Related analyzer scripts and CI examples are available at github.com/InventiveHQ/terraform-plan-risk-analyzer. Follow that repository's README for its documented commands.
What is Blast Radius?
Blast radius is the potential scope of impact from a Terraform change. It answers the question: "If this change goes wrong, what else breaks?"
Direct vs Indirect Impact
Direct impact: Resources explicitly changed in the plan
# Changing this database instance
resource "aws_db_instance" "main" {
instance_class = "db.t3.medium" # Was: db.t3.small
}
Possible indirect impact: Resources or services that depend on the changed resource. These fragments illustrate references inside larger configurations:
# These resources depend on the database
resource "aws_lambda_function" "api" {
environment {
variables = {
DB_HOST = aws_db_instance.main.endpoint # ← Dependency
}
}
}
resource "aws_ecs_task_definition" "app" {
container_definitions = jsonencode([{
name = "app"
image = "example.com/app:tag"
essential = true
environment = [{
name = "DB_HOST"
value = aws_db_instance.main.endpoint # ← Dependency
}]
}])
}
# If a database replacement changes its endpoint,
# Lambda and ECS may need updated configuration or redeployment
Possible blast radius: 1 direct change with effects on the two shown consumers; verify the actual plan and application behavior.
Low vs High Blast Radius
Low blast radius example:
Change: Update Lambda function memory from 512MB to 1024MB
Direct impact:
- 1 Lambda function configuration
Indirect impact:
- Check whether callers depend on memory, latency, or cost characteristics
Risk level: Low
Safe to apply: Depends on testing and workload requirements
High blast radius example:
Change: Replace VPC CIDR block from 10.0.0.0/16 to 10.1.0.0/16
Direct impact:
- 1 VPC destroyed and recreated
Indirect impact:
- Dependent subnets and security groups may require replacement
- EC2, RDS, load balancers, and ECS services may need migration or reconfiguration
- Check the actual plan and external consumers for the affected scope
Risk level: Critical
Safe to apply: Assess the plan and prepare a migration before applying
Understanding Terraform Actions
Terraform plan output shows different action types. The symbol at the left of each line is a useful first check: it tells you whether Terraform is adding, editing in place, replacing, or destroying a resource. Assess the resource and configuration before assigning risk:
Create (+)
Risk level: Depends on the resource and its exposure
Description: Adding new resources
+ aws_s3_bucket.logs
bucket = "my-app-logs-2025"
acl = "private"
Risks:
- Resource naming conflicts
- Quota limits exceeded
- Unintended public exposure (if misconfigured)
Review checklist:
☐ Does resource name follow naming conventions?
☐ Are security settings appropriate (private, encrypted)?
☐ Will this exceed any quotas or limits?
☐ Are tags present for cost tracking?
Update (~)
Risk level: Low to High (depends on what's changing)
Description: Modifying existing resources in-place
~ aws_instance.web
instance_type = "t3.small" -> "t3.medium"
Risks:
- Service interruption during update
- Unexpected behavior with new configuration
- Cost increase
Review checklist:
☐ Is change non-disruptive (or acceptable disruption)?
☐ Can change be rolled back easily?
☐ Are dependent resources compatible with change?
☐ Is change tested in non-production first?
Replace (-/+)
Risk level: Depends on data, dependencies, and migration options
Description: Destroying then recreating resource (forced replacement)
-/+ aws_instance.web (forces replacement)
ami = "ami-previous" -> "ami-new"
Why replacement occurs:
- Attribute requires resource recreation
- Resource ID or ARN will change
- Downstream dependencies may break
Common forced replacements:
| Resource Type | Attribute | Why Replacement Needed |
|---|---|---|
| aws_instance | ami | Different image = new instance |
| aws_vpc | cidr_block | VPC CIDR is immutable |
| aws_subnet | availability_zone | Subnet AZ is immutable |
| aws_s3_bucket | bucket name | Bucket names are immutable |
| aws_iam_role | name | Role ARN includes name |
Review checklist:
☐ Why is replacement required? (Check (forces replacement) reason)
☐ What depends on this resource's ID/ARN?
☐ Is there data that will be lost? (EBS volumes, database data)
☐ Can we create new resource before destroying old? (create_before_destroy)
☐ Do we have backups?
☐ Is rollback plan documented?
Delete (-)
Risk level: Depends on the resource and recovery options
Description: Removing resources permanently
- aws_s3_bucket.old_data
bucket = "deprecated-bucket"
Risks:
- Permanent data loss
- Breaking dependent resources
- Difficult to recover
Review checklist:
☐ Is data backed up?
☐ Are there dependencies in other Terraform states/workspaces?
☐ Are there manual resources depending on this?
☐ Is deletion intentional (not accidental removal from code)?
☐ Should resource be imported elsewhere before deletion?
Risk Scoring Framework
Not all changes are equal. Use this framework to assess risk:
Resource Type Risk
Critical risk (score: 10):
- VPCs and networking (VPC, subnets, route tables)
- Databases (RDS, DynamoDB, DocumentDB)
- State storage (S3 buckets with state files)
- IAM roles and policies (privilege escalation risk)
- Security groups (network exposure)
High risk (score: 7-9):
- Compute instances (EC2, ECS, Lambda)
- Load balancers (ALB, NLB)
- DNS records (Route53)
- Certificates (ACM)
- Encryption keys (KMS)
Medium risk (score: 4-6):
- Monitoring and logs (CloudWatch, S3 logs)
- Caching (ElastiCache, CloudFront)
- Queues (SQS, SNS)
- API Gateway configurations
Low risk (score: 1-3):
- Tags
- CloudWatch dashboards
- Parameter Store values
- S3 bucket policies (non-critical buckets)
Action Type Risk
The following weights are an illustrative team rubric, not generally predictive values. Calibrate them to your environment and validate the actual plan.
Delete: ×3 multiplier
Replace: ×2 multiplier
Update: ×1 multiplier
Create: ×0.5 multiplier
Environment Risk
Production: ×2 multiplier
Staging: ×1 multiplier
Development: ×0.5 multiplier
Blast Radius Risk
Affects 20+ resources: +10 points
Affects 10-19 resources: +5 points
Affects 5-9 resources: +3 points
Affects 1-4 resources: +1 point
Overall Risk Score
Illustrative Risk Score = (Resource Type Score × Action Multiplier × Environment Multiplier) + Blast Radius Points
Example calculation:
Hypothetical change: Replace a production VPC after a CIDR change
Resource Type: VPC (Critical = 10)
Action: Replace (×2)
Environment: Production (×2)
Blast Radius: Hypothetical 10-19 affected resources (+5)
Risk Score = (10 × 2 × 2) + 5 = 45
Risk Level: CRITICAL (score > 40)
→ Requires: Architecture review, runbook, off-hours deployment, rollback plan
Security Risk Detection
Terraform plans can introduce security vulnerabilities. Here are common patterns to detect:
1. Public Network Exposure
Critical: Opening SSH/RDP to 0.0.0.0/0
resource "aws_security_group_rule" "ssh" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # ⚠️ CRITICAL: SSH open to entire internet
}
Fix:
resource "aws_security_group_rule" "ssh" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.0/8"] # Example private CIDR; use your verified VPN or admin source range
}
Confirm the source CIDR in your network configuration and restrict SSH to the actual authorized range. A private CIDR alone does not establish that traffic comes through your VPN.
2. Public S3 Buckets
Review signal: A public-read S3 bucket ACL can allow public reads when ACLs are enabled and public-access blocks do not prevent them. Check object ACLs, bucket policy, ownership settings, and account and bucket public-access blocks.
resource "aws_s3_bucket_acl" "public" {
bucket = aws_s3_bucket.data.id
acl = "public-read" # ⚠️ Review potential public access
}
Fix:
resource "aws_s3_bucket_acl" "private" {
bucket = aws_s3_bucket.data.id
acl = "private" # ✅ Removes public read from this bucket ACL
}
resource "aws_s3_bucket_public_access_block" "block" {
bucket = aws_s3_bucket.data.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
3. Publicly Accessible Databases
Review signal: publicly_accessible = true can assign a public address; internet reachability also depends on routing, security groups, and network ACLs.
resource "aws_db_instance" "main" {
publicly_accessible = true # ⚠️ Review network paths and access controls
# ...
}
Fix:
resource "aws_db_instance" "main" {
publicly_accessible = false # ✅ No public address for this instance
# ...
}
4. Disabling Encryption
Review signal: Removing an explicit S3 bucket encryption configuration can change the default encryption mode for new uploads. It does not leave the bucket unencrypted: S3 uses SSE-S3 by default. If the removed configuration specified SSE-KMS or another required mode, check the effect against your policy and applications. Existing objects are not re-encrypted by changing the bucket default. See Amazon S3 default encryption and DeleteBucketEncryption.
- aws_s3_bucket_server_side_encryption_configuration.data
Example when an explicit SSE-S3 configuration is required:
resource "aws_s3_bucket_server_side_encryption_configuration" "data" {
bucket = aws_s3_bucket.data.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256" # Explicit SSE-S3 default
}
}
}
If the prior default was SSE-KMS, restore the required KMS configuration instead; the SSE-S3 example does not preserve KMS key usage.
5. IAM Privilege Escalation
Critical: Granting excessive IAM permissions
resource "aws_iam_policy" "admin" {
policy = jsonencode({
Statement = [{
Effect = "Allow"
Action = "*" # ⚠️ CRITICAL: Full admin access
Resource = "*"
}]
})
}
Fix:
resource "aws_iam_policy" "limited" {
policy = jsonencode({
Statement = [{
Effect = "Allow"
Action = [
"s3:GetObject", # ✅ Specific permissions only
"s3:PutObject"
]
Resource = "arn:aws:s3:::specific-bucket/*"
}]
})
}
Real-World Dangerous Terraform Changes
These simplified scenarios illustrate changes that warrant review. The excerpts and impacts are hypothetical; validate each against your own plan and configuration.
Scenario 1: VPC CIDR Change
Illustrative plan excerpt:
-/+ aws_vpc.main (forces replacement)
cidr_block = "10.0.0.0/16" -> "10.1.0.0/16"
-/+ aws_subnet.private_a (forces replacement)
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24" -> "10.1.1.0/24"
# ... other resources may also be affected
Blast radius: Review the actual plan and affected dependencies
Risk level: CRITICAL
Why dangerous:
- Dependent subnets, route tables, and security groups may require replacement or reconfiguration
- EC2 connectivity and other workloads may be disrupted
- New IP addresses can break hardcoded references
- A direct replacement can interrupt service; plan a staged migration if continuity is required
Safe approach:
- Create parallel VPC:
resource "aws_vpc" "new" {
cidr_block = "10.1.0.0/16"
}
resource "aws_vpc_peering_connection" "migration" {
vpc_id = aws_vpc.main.id
peer_vpc_id = aws_vpc.new.id
}
- Migrate workloads incrementally
- Update DNS/load balancers to point to new VPC
- Decommission old VPC after validation
Scenario 2: RDS Instance Class Change
Illustrative plan excerpt:
~ aws_db_instance.main (update in-place)
instance_class = "db.t3.small" -> "db.t3.medium"
Blast radius: Check applications that connect to this database, including consumers outside this Terraform state
Risk level: HIGH (assess the workload and maintenance window)
Why dangerous:
- The modification can interrupt database connections while RDS changes the instance class
- The change may take effect during a maintenance window unless configured to apply immediately
- Application capacity and compatibility need checking before the resize
Safe approach:
resource "aws_db_instance" "main" {
instance_class = "db.t3.medium"
apply_immediately = false # Schedule the modification for the maintenance window
}
Confirm a current backup and test the application against the new class before applying. A class change normally updates the instance in place; check the actual plan for any additional changes or replacement.
Alternative: Snapshot-based migration example:
A snapshot is a point-in-time copy. Writes after the snapshot are absent from the restored instance. Before switching the application endpoint, arrange a write pause and reconcile changes, or use a separately designed replication and cutover process. The following sketch does not by itself provide a zero-data-loss cutover.
# Take a snapshot for a separately planned migration
resource "aws_db_snapshot" "main_cutover" {
db_instance_identifier = aws_db_instance.main.id
db_snapshot_identifier = "main-cutover-snapshot" # Choose a unique, stable name
}
# Create a separate database instance from that snapshot
resource "aws_db_instance" "main_new" {
identifier = "main-new"
instance_class = "db.t3.medium"
snapshot_identifier = aws_db_snapshot.main_cutover.id
}
# Update application only after write consistency and cutover are handled
resource "aws_ssm_parameter" "db_endpoint" {
name = "/app/db/endpoint"
value = aws_db_instance.main_new.endpoint # Planned cutover
}
# After validating data and application behavior, retire the old instance
# resource "aws_db_instance" "main" { ... } # Remove from code
Scenario 3: Security Group Deletion
Illustrative plan excerpt:
- aws_security_group.api
# Inspect instance and other references before deletion
Blast radius: Depends on resources that reference this group and the order of changes
Risk level: HIGH to CRITICAL
Why dangerous:
- Instances may become unreachable
- AWS doesn't allow deleting security groups still in use
- Deletion can fail if references remain
Safe approach:
Step 1: Identify dependencies
aws ec2 describe-instances \
--filters "Name=instance.group-id,Values=sg-12345678" \
--query 'Reservations[].Instances[].InstanceId'
Step 2: Create replacement security group
resource "aws_security_group" "api_v2" {
name = "api-v2"
# ... same rules as old security group
}
Step 3: Update instance references
resource "aws_instance" "api" {
vpc_security_group_ids = [
aws_security_group.api_v2.id # New security group
]
}
Step 4: Apply changes (instances switch to new SG)
Step 5: Delete old security group
# Remove from code:
# resource "aws_security_group" "api" { ... }
Scenario 4: Load Balancer Target Group Changes
Illustrative plan excerpt:
-/+ aws_lb_target_group.api (forces replacement)
port = 80 -> 8080
Blast radius: Check target attachments, listeners, rules, and external consumers
Risk level: HIGH
Why dangerous:
- Target group ARN changes
- Listener rules referencing the old ARN need updating
- Traffic can stop if the listener switches before healthy targets are ready
- A staged cutover may be needed to avoid interruption
Staged cutover example: Keep the existing /api/* listener rule forwarding to the old target group during the first apply. The following first-stage configuration creates the new group, registers the intended instances, and attaches it to the ALB through a temporary probe rule. An ALB target group needs a listener rule before its targets can complete health checks; see AWS target group health checks. Choose an unused probe path and priority, configure a health check path your application serves on port 8080, and allow the ALB to reach that port.
# First apply: create and register the new target group
resource "aws_lb_target_group" "api_v2" {
name = "api-v2"
port = 8080
protocol = "HTTP"
vpc_id = aws_vpc.main.id
}
resource "aws_lb_target_group_attachment" "api_v2" {
for_each = toset(var.instance_ids)
target_group_arn = aws_lb_target_group.api_v2.arn
target_id = each.value
port = 8080
}
resource "aws_lb_listener_rule" "api_v2_probe" {
listener_arn = aws_lb_listener.main.arn
priority = 101 # Choose an unused priority
action {
type = "forward"
target_group_arn = aws_lb_target_group.api_v2.arn
}
condition {
path_pattern {
values = ["/__api_v2_probe/*"]
}
}
}
After the first apply, inspect the new group with aws elbv2 describe-target-health --target-group-arn <new-target-group-arn>. Confirm that the expected instances are registered and each intended target is healthy on port 8080; AWS documents the target-health command. Resolve failed health checks before proceeding.
For the second apply, change the existing /api/* listener rule to target_group_arn = aws_lb_target_group.api_v2.arn. Review the plan to confirm the production rule changes without removing the old group yet. After traffic and application behavior are validated, remove the old target group and the temporary probe rule in a later apply.
Terraform Plan Review Checklist
Before running terraform apply, systematically review:
1. Understand Every Change
☐ Do I understand why each resource is changing?
☐ Are there unexpected changes? (indicates drift or unintended edits)
☐ Do I see any forced replacements? (Look for (forces replacement))
2. Check for Dangerous Patterns
☐ Any deletions? Are they intentional?
☐ Any forced replacements? What depends on them?
☐ Any 0.0.0.0/0 in security groups?
☐ Any public S3 bucket ACLs?
☐ Any publicly_accessible databases?
☐ Any IAM permission escalations?
☐ Any encryption being removed?
3. Assess Blast Radius
☐ How many resources directly affected?
☐ What depends on changed resources? (Inspect terraform graph, configuration, other states, and external consumers)
☐ Are there dependencies outside this Terraform state?
☐ What breaks if this change fails halfway through?
4. Validate Testing
☐ Was this change tested in non-production first?
☐ Do we have automated tests covering this change?
☐ Has peer review been completed?
☐ Is change documented in pull request?
5. Prepare for Failure
☐ Do we have backups of data that could be lost?
☐ Can we rollback if something goes wrong?
☐ Is rollback plan documented?
☐ Do we have monitoring/alerting for the changed resources?
☐ Is there an incident response runbook?
6. Timing and Communication
☐ Is this a good time to make this change? (Off-peak hours?)
☐ Have stakeholders been notified?
☐ Is there a maintenance window if needed?
☐ Are on-call engineers aware and ready?
Using Terraform JSON Plans for Analysis
Human-readable plan output is great for review, but JSON plans enable automated analysis:
Generate JSON Plan
# Create plan file
terraform plan -out=tfplan
# Convert to JSON
terraform show -json tfplan > plan.json
The saved plan and exported JSON can include sensitive values, including values hidden in the human-readable plan. Restrict access to both files, avoid committing or publishing them, and delete local or CI copies when no longer needed. See Terraform's guidance on sensitive data.
JSON Plan Structure
{
"resource_changes": [
{
"address": "aws_instance.web",
"mode": "managed",
"type": "aws_instance",
"name": "web",
"provider_name": "registry.terraform.io/hashicorp/aws",
"change": {
"actions": ["update"],
"before": { "instance_type": "t3.small" },
"after": { "instance_type": "t3.medium" },
"after_unknown": {},
"before_sensitive": {},
"after_sensitive": {},
"replace_paths": []
}
}
]
}
Automated Risk Analysis Script
This minimal example scores delete and replace actions once each and checks only two security patterns: public SSH/RDP rules and public-read S3 ACLs. The findings require review of effective network and S3 access controls. The linked repository contains a separate analyzer with its own documented behavior.
import json
import sys
def analyze_terraform_plan(plan_file):
with open(plan_file) as f:
plan = json.load(f)
risk_score = 0
critical_issues = []
for change in plan['resource_changes']:
resource = change['address']
actions = change['change']['actions']
# Detect dangerous actions
if 'create' in actions and 'delete' in actions:
risk_score += 8
critical_issues.append(f"⚠️ REPLACE: {resource}")
elif 'delete' in actions:
risk_score += 10
critical_issues.append(f"⚠️ DELETE: {resource}")
# Check two security patterns in resources with proposed after values
after = change['change'].get('after') or {}
if change['type'] == 'aws_security_group_rule':
if '0.0.0.0/0' in (after.get('cidr_blocks') or []):
if after.get('from_port') in [22, 3389]:
risk_score += 15
critical_issues.append(
f"⚠️ REVIEW: {resource} allows SSH/RDP from 0.0.0.0/0"
)
if change['type'] == 'aws_s3_bucket_acl':
if after.get('acl') == 'public-read':
risk_score += 12
critical_issues.append(
f"⚠️ REVIEW: {resource} sets a public-read S3 ACL"
)
# Generate report
print(f"\n{'='*60}")
print(f"Terraform Plan Risk Analysis")
print(f"{'='*60}")
print(f"Risk Score: {risk_score}")
if risk_score > 40:
print(f"Risk Level: CRITICAL ⛔")
elif risk_score > 20:
print(f"Risk Level: HIGH ⚠️")
elif risk_score > 10:
print(f"Risk Level: MEDIUM ⚡")
else:
print(f"Risk Level: LOW ✅")
if critical_issues:
print(f"\nCritical Issues:")
for issue in critical_issues:
print(f" {issue}")
return risk_score
# Usage
risk_score = analyze_terraform_plan(sys.argv[1])
if risk_score > 40:
print("\n🚨 BLOCKED: Change requires architecture review")
exit(1)
CI/CD Integration
# GitHub Actions example
name: Terraform Plan Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: |
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
- name: Analyze Plan and Block High-Risk Changes
run: python3 scripts/analyze_plan.py plan.json
Save the Python example above as scripts/analyze_plan.py in the same repository as this workflow before using the CI example. actions/checkout checks out that repository; it does not fetch the separate linked analyzer repository. The example script exits nonzero when its score exceeds 40; adjust that illustrative threshold and review its limited checks before relying on it as a merge gate. Treat the CI workspace and logs as sensitive because the plan can contain secrets.
Conclusion
Terraform is powerful, but with great power comes great responsibility. Understanding blast radius, recognizing dangerous changes, and systematically reviewing plans before applying them is essential for maintaining reliable infrastructure.
Key principles:
- Blast radius includes direct and possible indirect effects: Review downstream impact
- Forced replacements can be disruptive: Resources with (forces replacement) deserve extra scrutiny
- Deletions can cause loss: Verify backups and dependencies before deleting resources
- Security patterns are detectable: Look for 0.0.0.0/0, public buckets, privilege escalation
- JSON plans enable automation: Integrate risk analysis into CI/CD pipelines
- Test in non-production first: Test production changes where a representative environment is available
- Have a rollback plan: Document how to revert if something goes wrong
The moment before terraform apply should be confident, not terrifying. By understanding risk, analyzing blast radius, and following systematic review processes, you can make infrastructure changes safely and predictably.
Need help reviewing Terraform plans? Try our Terraform Plan Explainer to inspect plan changes, flag possible security issues, and organize risk review before applying changes. Check its findings against dependencies and controls outside the plan.