Skip to content
Back to blog
2 min read

AWS ECS Maintenance Mode with ALB Fixed Responses

Using Application Load Balancer fixed responses to protect ECS deployments during maintenance windows and risky releases.

AWS ECS Terraform DevOps

Maintenance mode is most useful when it is boring. For ECS services behind an Application Load Balancer, a fixed-response rule can provide a simple switch that keeps users away from a risky deployment path while preserving a clear operational signal.

The Pattern

Create a high-priority ALB listener rule that returns a fixed response when maintenance mode is enabled. Keep the normal target group rule intact underneath it.

resource "aws_lb_listener_rule" "maintenance" {
  listener_arn = aws_lb_listener.https.arn
  priority     = 10

  action {
    type = "fixed-response"

    fixed_response {
      content_type = "text/html"
      status_code  = "503"
      message_body = "Service maintenance in progress."
    }
  }

  condition {
    path_pattern {
      values = ["/*"]
    }
  }
}

Deployment Safety

This pattern is useful when:

  • database migrations need a quiet window
  • a rollback may require target group stabilization
  • a service is draining tasks and should not accept user traffic
  • an incident team needs to isolate an application tier

Operational Details

Prefer a 503 status code so clients and monitoring systems understand that the service is temporarily unavailable. Add a clear runbook step for enabling and disabling the listener rule, and make sure health checks still reflect the real service state.

Tradeoffs

ALB fixed responses are blunt. They do not support personalized state or complex maintenance pages. That simplicity is also the advantage: fewer moving parts, fast rollback, and easy Terraform review.