Description
Enable deletion protection on production Application Load Balancers (ALBs). AWS rejects requests to delete a protected ALB.
Potential impact
Deleting the ALB can interrupt traffic until its entry point and connections are restored.
Remediation
Set enable_deletion_protection = true on aws_lb, or use the equivalent module input. Before a planned removal, follow your change process to disable protection, apply that change, then delete the ALB.
Examples
The two excerpts refer to the same ALB and subnets. Only the deletion-protection setting changes.
Before
hcl
resource "aws_lb" "app_lb" {
name = "test-lb-tf"
load_balancer_type = "application"
subnets = aws_subnet.public.*.id
enable_deletion_protection = false
}
After
hcl
resource "aws_lb" "app_lb" {
name = "test-lb-tf"
load_balancer_type = "application"
subnets = aws_subnet.public.*.id
enable_deletion_protection = true
}