I was wondering if it is possible to monitor all AWS cluster environments by default. We currently have two clusters and we monitor them by having a class that creates a DescribeEnvironmentResourcesRequest request like this:
for (String cluster : clusters) {
DescribeEnvironmentResourcesRequest request = new DescribeEnvironmentResourcesRequest();
request.setEnvironmentName(cluster);
//Code to get all beanstalk annd EC2 instances for this cluster.
The problem with this is , everytime we add a new cluster, we will have to modify our list of clusters (which is stored in a properties file ), redeploy this application and only then will we be able to monitor the instances in the new cluster.
Is there a way to let AWS auto discover new clusters as and when they are added, so that it solves the issue?
Use DescribeEnvironments to retrieve a current list of available environments. From that list you get the environment resources.
API Docs: http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DescribeEnvironments.html CLI Docs: http://docs.aws.amazon.com/cli/latest/reference/elasticbeanstalk/describe-environments.html