Example usage for com.amazonaws.services.ecs.model DeploymentConfiguration DeploymentConfiguration

List of usage examples for com.amazonaws.services.ecs.model DeploymentConfiguration DeploymentConfiguration

Introduction

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

Prototype

DeploymentConfiguration

Source Link

Usage

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) {//w  w w  .j a  v a2  s  .  c o m
    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;
}