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

This example registers the specified instance with the specified load balancer.

Command:

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" } ] }
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