Example usage for com.amazonaws.services.ecs AmazonECS stopTask

List of usage examples for com.amazonaws.services.ecs AmazonECS stopTask

Introduction

In this page you can find the example usage for com.amazonaws.services.ecs AmazonECS stopTask.

Prototype

StopTaskResult stopTask(StopTaskRequest stopTaskRequest);

Source Link

Document

Stops a running task.

Usage

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

License:Apache License

@Override
public Void operate(List priorOutputs) {
    updateTaskStatus("Initializing Terminate ECS Instances Operation...");
    AmazonECS ecs = getAmazonEcsClient();

    for (String taskId : description.getEcsTaskIds()) {
        updateTaskStatus("Terminating instance: " + taskId);
        String clusterArn = containerInformationService.getClusterArn(description.getCredentialAccount(),
                description.getRegion(), taskId);
        StopTaskRequest request = new StopTaskRequest().withTask(taskId).withCluster(clusterArn);
        ecs.stopTask(request);
    }/*from  w  ww  .j a  v a  2 s. c  o m*/

    return null;
}

From source file:com.remediatetheflag.global.utils.AWSHelper.java

License:Apache License

public void terminateTask(String taskArn) {
    String regionFromArn = taskArn.split(":")[3];
    AmazonECS client = AmazonECSClientBuilder.standard().withRegion(regionFromArn)
            .withCredentials(new DefaultAWSCredentialsProviderChain()).build();
    try {//from ww w.j a  v  a2s  . c om
        StopTaskRequest stopTaskRequest = new StopTaskRequest();
        stopTaskRequest.withCluster(RTFConfig.getExercisesCluster()).withTask(taskArn);
        client.stopTask(stopTaskRequest);
    } catch (Exception e) {
        logger.error("Error terminating task " + e.getMessage());
    }
}

From source file:com.remediatetheflag.global.utils.AWSHelper.java

License:Apache License

public void terminateTask(RTFECSContainerTask ecsInstance) {
    AmazonECS client = AmazonECSClientBuilder.standard().withRegion(ecsInstance.getRegion())
            .withCredentials(new DefaultAWSCredentialsProviderChain()).build();
    try {// w  ww  .j  a v a 2 s  . c o m
        StopTaskRequest stopTaskRequest = new StopTaskRequest();
        stopTaskRequest.withCluster(RTFConfig.getExercisesCluster()).withTask(ecsInstance.getTaskArn());
        client.stopTask(stopTaskRequest);
    } catch (Exception e) {
        logger.error("Error terminating task " + e.getMessage());
    }
}