The blue-green deployment pattern uses two identical environments (blue and green). Traffic switches from one to the other to deploy updates without downtime.
resource "aws_lb_listener_rule" "green_traffic" { listener_arn = aws_lb_listener.front_end.arn priority = 100 action { type = "forward" target_group_arn = aws_lb_target_group.green.arn } condition { path_pattern { values = ["/app/*"] } } }
To switch traffic, the listener rule forwarding to the green target group must have a higher priority than the blue's rule so it takes precedence.
Running two environments simultaneously means both are accessible, increasing the potential attack surface if not properly secured.
Applying backward-compatible schema changes first ensures both environments work with the database, avoiding downtime during traffic switch.
Sticky sessions keep users bound to their original environment until the session expires, so existing users stay on blue while new users go to green.
