List of usage examples for com.amazonaws.services.ecs.model CreateServiceRequest CreateServiceRequest
CreateServiceRequest
From source file:com.netflix.spinnaker.clouddriver.ecs.deploy.ops.CreateServerGroupAtomicOperation.java
License:Apache License
private Service createService(AmazonECS ecs, TaskDefinition taskDefinition, String ecsServiceRole, String version) {/*from w w w.j ava2s . c om*/ String serviceName = getNextServiceName(version); Collection<LoadBalancer> loadBalancers = new LinkedList<>(); loadBalancers.add(retrieveLoadBalancer(version)); Integer desiredCount = description.getCapacity().getDesired(); String taskDefinitionArn = taskDefinition.getTaskDefinitionArn(); DeploymentConfiguration deploymentConfiguration = new DeploymentConfiguration() .withMinimumHealthyPercent(100).withMaximumPercent(200); CreateServiceRequest request = new CreateServiceRequest().withServiceName(serviceName) .withDesiredCount(desiredCount).withCluster(description.getEcsClusterName()) .withRole(ecsServiceRole).withLoadBalancers(loadBalancers).withTaskDefinition(taskDefinitionArn) .withPlacementStrategy(description.getPlacementStrategySequence()) .withDeploymentConfiguration(deploymentConfiguration); updateTaskStatus(String.format("Creating %s of %s with %s for %s.", desiredCount, serviceName, taskDefinitionArn, description.getCredentialAccount())); Service service = ecs.createService(request).getService(); updateTaskStatus(String.format("Done creating %s of %s with %s for %s.", desiredCount, serviceName, taskDefinitionArn, description.getCredentialAccount())); return service; }