Вопрос

I'm having some trouble configuring parts of my Elastic Load Balancer in AWS. I don't have problems creating one but I'm having trouble figuring out how to configure the HealthCheck and what instances are connected behind the ELB.

Here's my code to create the ELB. This is all per the AWS API:

Listener Test_AS_Listener = new Listener()
    .withInstancePort(443)
    .withInstanceProtocol("HTTPS")
    .withLoadBalancerPort(443)
    .withProtocol("HTTPS")
    .withSSLCertificateId("arn:aws:iam::1111111111:server-certificate/test-certificate");

CreateLoadBalancerRequest lbReq = new CreateLoadBalancerRequest()
    .withListeners(Test_AS_Listener)
    .withLoadBalancerName("TestLB")
    .withSecurityGroups("sg-11111111")
    .withSubnets("subnet-11111111");

HealthCheck healthCK = new HealthCheck()
    .withHealthyThreshold(2)
    .withInterval(30)
    .withTarget("TCP:443")
    .withTimeout(5)
    .withUnhealthyThreshold(2);

ConfigureHealthCheckRequest healthCheckReq = new ConfigureHealthCheckRequest()
    .withHealthCheck(healthCK)
    .withLoadBalancerName("TestLB");
ConfigureHealthCheckResult confChkResult = new ConfigureHealthCheckResult()
    .withHealthCheck(healthCK);

Instance inst = new Instance("i-11111111")
    .withInstanceId("TestLB");

CreateLoadBalancerResult result = myELB.createLoadBalancer(lbReq);

Looking in the Javadocs for the CreateLoadBalancer method, I don't see where I can plug in the information about the health check and connecting my instance behind the ELB. Can someone point me to the correct class/method to do this please?

When I run my code, I can create an ELB that listens on the correct port/protocols as well as use the correct security groups, vpc, etc. I just can't figure out how to make it route traffic to the correct instances or have the correct health check.

Thanks in advance for your help.

Это было полезно?

Решение

My bad. Forgot to execute the requests against the ELB variable. The code below creates the health check and assigns the instances associated with the ELB. Hope this helps the next person asking this question.

ConfigureHealthCheckResult healthResult = myELB.configureHealthCheck(healthCheckReq);
RegisterInstancesWithLoadBalancerResult registerResult = myELB.registerInstancesWithLoadBalancer(regInst);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top