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

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

Introduction

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

Prototype


public void setContainerName(String containerName) 

Source Link

Document

The name of the container (as it appears in a container definition) 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//w  w w  .j  av a  2s.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;
}