private final static String ACCESS_KEY = "YYYYYYYYYYY"; private final static String SECRET_ACCESS_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; AWSCredentials awsCredentials = new BasicAWSCredentials(ACCESS_KEY, SECRET_ACCESS_KEY); AmazonCloudWatchClient awsClient = new AmazonCloudWatchClient( awsCredentials); String[] accountIds = { "xxxxxxxxxxx", "yyyyyyyyyyyyy", "zzzzzzzzzzzzzzz" }; double currentBillingValue = 0; for (String accountId : accountIds) { ListMetricsRequest request = new ListMetricsRequest(); ListMetricsResult list = awsClient.listMetrics(request); GetMetricStatisticsRequest getMetricStatisticsRequest = new GetMetricStatisticsRequest(); Date date = new Date(); getMetricStatisticsRequest.setStartTime(new Date(date.getTime() - (24 * 3600 * 1 * 1000))); getMetricStatisticsRequest.setEndTime(new Date()); getMetricStatisticsRequest.setMetricName("EstimatedCharges"); getMetricStatisticsRequest.setNamespace("AWS/Billing"); getMetricStatisticsRequest.setPeriod(86400); Collection<Dimension> dimensions = new ArrayList<Dimension>(); Dimension accountDimension = new Dimension(); accountDimension.setName("LinkedAccount"); accountDimension.setValue(accountId); dimensions.add(accountDimension); Dimension currenctDimension = new Dimension(); currenctDimension.setName("Currency"); currenctDimension.setValue("USD"); dimensions.add(currenctDimension); getMetricStatisticsRequest.setDimensions(dimensions); Collection<String> statistics = new ArrayList<String>(); statistics.add("Maximum"); getMetricStatisticsRequest.setStatistics(statistics); awsClient.getMetricStatistics(getMetricStatisticsRequest); GetMetricStatisticsResult getMetricStatisticsResult = awsClient .getMetricStatistics(getMetricStatisticsRequest); List<Datapoint> dataPoints = getMetricStatisticsResult .getDatapoints(); Collections.sort(dataPoints, new DataPointComparator()); if (dataPoints.size() > 0) { currentBillingValue += dataPoints.get(dataPoints.size() - 1).getMaximum(); }