View a markdown version of this page

Use RegisterInstancesWithLoadBalancer with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use RegisterInstancesWithLoadBalancer with a CLI

The following code examples show how to use RegisterInstancesWithLoadBalancer.

CLI
AWS CLI

To register instances with a load balancer

The following register-instances-with-load-balancer example registers the specified instance with the specified load balancer.

aws elb register-instances-with-load-balancer \ --load-balancer-name my-load-balancer \ --instances i-d6f6fae3

Output:

{ "Instances": [ { "InstanceId": "i-d6f6fae3" }, { "InstanceId": "i-207d9717" }, { "InstanceId": "i-afefb49b" } ] }

For more information, see Register instances with your Classic Load Balancer in the Classic Load Balancers Guide.

PowerShell
Tools for PowerShell V4

Example 1: This example registers the specified EC2 instance with the specified load balancer.

Register-ELBInstanceWithLoadBalancer -LoadBalancerName my-load-balancer -Instance i-12345678

Output:

InstanceId ---------- i-12345678 i-87654321
Tools for PowerShell V5

Example 1: This example registers the specified EC2 instance with the specified load balancer.

Register-ELBInstanceWithLoadBalancer -LoadBalancerName my-load-balancer -Instance i-12345678

Output:

InstanceId ---------- i-12345678 i-87654321