as part of a project i need to create a new load balancer on amazon AWS.
i need to do it using the java sdk
how can i set the load balancer up using code?
here is what i tried so far without success.
//create load balancer
CreateLoadBalancerRequest lbRequest = new CreateLoadBalancerRequest();
lbRequest.setLoadBalancerName("loader");
List<Listener> listeners = new ArrayList<Listener>(1);
listeners.add(new Listener("HTTP", 80, 80));
lbRequest.withAvailabilityZones(availabilityZone1,availabilityZone2);
lbRequest.setListeners(listeners);
CreateLoadBalancerResult lbResult=new CreateLoadBalancerResult();
System.out.println("created load balancer loader");
well finelly i got it:
first create an elb client
then
use it to initiate the request
then register your instances to the Load balancer
and you are done…