List<String> listTaskPrivateAddresses(String cluster, AwsCredentials credentials) {
        LOGGER.fine("Listing tasks from cluster: '%s'", cluster);
        List<String> taskArns = listTasks(cluster, credentials);
        LOGGER.fine("AWS ECS ListTasks found the following tasks: %s", taskArns);
        if (!taskArns.isEmpty()) {
            List<Task> tasks = describeTasks(cluster, taskArns, credentials);
            if (!tasks.isEmpty()) {
                return tasks.stream().map(Task::getPrivateAddress).collect(Collectors.toList());
            }
        }
        return emptyList();
    }
@Test
    public void awsError() {
        // given
        int errorCode = HttpURLConnection.HTTP_UNAUTHORIZED;
        String errorMessage = "Error message retrieved from AWS";
        stubFor(post(urlMatching("/.*"))
                .willReturn(aResponse().withStatus(errorCode).withBody(errorMessage)));

        // when
        Exception exception = assertThrows(
                Exception.class, () -> awsEcsApi.listTaskPrivateAddresses("cluster-arn", CREDENTIALS));

        // then
        assertTrue(exception.getMessage().contains(Integer.toString(errorCode)));
        assertTrue(exception.getMessage().contains(errorMessage));
    }