How to Disable an Availability Zone from a Load Balanced Application
In this example, you disable the Availability Zone us-east-1a for your EC2 application.
This scenario assumes that you have an HTTP LoadBalancer enabled in Availability Zones us-east-1a and us-east-1b.
You disable the Availability Zone for the LoadBalancer first, then give the instances time to go into the OutOfService state before deregistering them from your LoadBalancer.
Note | |
---|---|
Your LoadBalancer always distributes traffic to all the enabled Availability Zones. If all the instances in an Availability Zone are deregistered or unhealthy before that Availability Zone is disabled for the LoadBalancer, all requests sent to that Availability Zone will fail until DisableAvailabilityZonesForLoadBalancer calls for that Availability Zone. |
API Example
To disable an availability zone from a Load Balanced Application
-
Call DisableAvailabilityZonesForLoadBalancer with the following parameters:
-
LoadBalancerName
=MyLoadBalancer
-
Availability Zones =
us-east-1a
The operation returns the updated list of Availability Zones enabled for your LoadBalancer.
-
-
Call DescribeInstanceHealth with the following parameters. You have to wait until all of the instances in the disabled Availability Zones are in the OutOfService state.
-
LoadBalancerName
=MyLoadBalancer
-
Instances =
i-4f8cf126
,i-0bb7ca62
-
-
Call DeregisterInstancesFromLoadBalancer with the following parameters:
-
LoadBalancerName
=MyLoadBalancer
-
Instances =
i-4f8cf126
,i-0bb7ca62
-
Command Line Tools Example
-
Use the elb-disable-zones-for-lb command as in the following example.
PROMPT> elb-disable-zones-for-lb MyLoadBalancer --headers --availability-zones us-east-1a
Elastic Load Balancing returns the following:
AVAILABILITY_ZONES AVAILABILITY-ZONES AVAILABILITY_ZONES us-east-1b
-
Use the elb-describe-instance-health command as in the following example.
PROMPT> elb-describe-instance-health MyLoadBalancer --headers --instances i-4f8cf126,i-0bb7ca62
Elastic Load Balancing returns the following:
INSTANCE INSTANCE-ID STATE INSTANCE i-4f8cf126 OutOfService INSTANCE i-0bb7ca62 OutOfService
Note Only when the instances are in the OutOfService state can you progress to the next step. -
Use the elb-deregister-instances-from-lb command as in the following example.
PROMPT> elb-deregister-instances-from-lb MyLoadBalancer --headers --instances i-4f8cf126,i-0bb7ca62
Elastic Load Balancing returns the following:
INSTANCE INSTANCE-ID INSTANCE i-3a8cf324 INSTANCE i-2603ca33
Give Us Your Feedback
Your input is important to us to help make our documentation helpful and easy to use. Please take a minute to give us your feedback on how well we were able to help you use Elastic Load Balancing. Just click this feedback link. Thank you.