Example usage for com.amazonaws.services.ecs.model StopTaskRequest withCluster

List of usage examples for com.amazonaws.services.ecs.model StopTaskRequest withCluster

Introduction

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

Prototype


public StopTaskRequest withCluster(String cluster) 

Source Link

Document

The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task to stop.

Usage

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