Example usage for com.amazonaws.services.ecs.model LoadBalancer setContainerPort

List of usage examples for com.amazonaws.services.ecs.model LoadBalancer setContainerPort

Introduction

In this page you can find the example usage for com.amazonaws.services.ecs.model LoadBalancer setContainerPort.

Prototype


public void setContainerPort(Integer containerPort) 

Source Link

Document

The port on the container to associate with the load balancer.

Usage

From source file:com.netflix.spinnaker.clouddriver.ecs.deploy.ops.CreateServerGroupAtomicOperation.java

License:Apache License

private LoadBalancer retrieveLoadBalancer(String version) {
    LoadBalancer loadBalancer = new LoadBalancer();
    loadBalancer.setContainerName(version);
    loadBalancer.setContainerPort(description.getContainerPort());

    if (description.getTargetGroup() != null) {
        AmazonElasticLoadBalancing loadBalancingV2 = getAmazonElasticLoadBalancingClient();

        DescribeTargetGroupsRequest request = new DescribeTargetGroupsRequest()
                .withNames(description.getTargetGroup());
        DescribeTargetGroupsResult describeTargetGroupsResult = loadBalancingV2.describeTargetGroups(request);

        if (describeTargetGroupsResult.getTargetGroups().size() == 1) {
            loadBalancer/*from  ww  w .  j  av a2s  . c om*/
                    .setTargetGroupArn(describeTargetGroupsResult.getTargetGroups().get(0).getTargetGroupArn());
        } else if (describeTargetGroupsResult.getTargetGroups().size() > 1) {
            throw new IllegalArgumentException(
                    "There are multiple target groups with the name " + description.getTargetGroup() + ".");
        } else {
            throw new IllegalArgumentException(
                    "There is no target group with the name " + description.getTargetGroup() + ".");
        }

    }
    return loadBalancer;
}