There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DeregisterInstancesFromLoadBalancer with a CLI
The following code examples show how to use DeregisterInstancesFromLoadBalancer.
- CLI
-
- AWS CLI
-
To deregister instances from a load balancer
This example deregisters the specified instance from the specified load balancer.
Command:
aws elb deregister-instances-from-load-balancer --load-balancer-namemy-load-balancer--instancesi-d6f6fae3Output:
{ "Instances": [ { "InstanceId": "i-207d9717" }, { "InstanceId": "i-afefb49b" } ] }-
For API details, see DeregisterInstancesFromLoadBalancer
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example removes the specified EC2 instance from the specified load balancer. You are prompted for confirmation before the operation proceeds, unless you also specify the Force parameter.
Remove-ELBInstanceFromLoadBalancer -LoadBalancerName my-load-balancer -Instance i-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-ELBInstanceFromLoadBalancer (DeregisterInstancesFromLoadBalancer)" on Target "Amazon.ElasticLoadBalancing.Model.Instance". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): InstanceId ---------- i-87654321-
For API details, see DeregisterInstancesFromLoadBalancer in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example removes the specified EC2 instance from the specified load balancer. You are prompted for confirmation before the operation proceeds, unless you also specify the Force parameter.
Remove-ELBInstanceFromLoadBalancer -LoadBalancerName my-load-balancer -Instance i-12345678Output:
Confirm Are you sure you want to perform this action? Performing operation "Remove-ELBInstanceFromLoadBalancer (DeregisterInstancesFromLoadBalancer)" on Target "Amazon.ElasticLoadBalancing.Model.Instance". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): InstanceId ---------- i-87654321-
For API details, see DeregisterInstancesFromLoadBalancer in AWS Tools for PowerShell Cmdlet Reference (V5).
-