List of usage examples for com.amazonaws.services.ecs.model StopTaskRequest withCluster
public StopTaskRequest withCluster(String cluster)
The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task to stop.
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()); } }