Repository: cloud-custodian/cloud-custodian

Issue:
aws.elasticsearch Error Scanning More Than 5 domains
**Describe the bug**
When running any elasticsearch policy on an account region with more than 5 elasticsearch domains the policy now bombs out with the error - ```error:An error occurred (ValidationException) when calling the DescribeElasticsearchDomains operation: Please provide a maximum of 5 Elasticsearch domain names to describe.```

**To Reproduce**
Create 6 es domains and run an elasticsearch c7n policy, error will occur

**Expected behavior**
It should chunk the calls into domains of 5 or less


**Background (please complete the following information):**
 - OS: Ubuntu v20
 - Python Version: 3.8
 - Custodian Version: 0.9.2.0
 - Tool Version: [if applicable]
 - Cloud Provider: aws
 - Policy:  any policy which queries ES
 - Traceback: 
```
[ERROR]	2020-05-22T14:51:25.978Z	9ef7929b-b494-434e-9f9f-dfdfdfdfdfdfd Error while executing policy
Traceback (most recent call last):
  File "/var/task/c7n/policy.py", line 291, in run
    resources = self.policy.resource_manager.resources()
  File "/var/task/c7n/query.py", line 466, in resources
    resources = self.augment(resources)
  File "/var/task/c7n/query.py", line 521, in augment
    return self.source.augment(resources)
  File "/var/task/c7n/resources/elasticsearch.py", line 48, in augment
    return _augment(domains)
  File "/var/task/c7n/resources/elasticsearch.py", line 39, in _augment
    resources = self.manager.retry(
  File "/var/task/c7n/utils.py", line 373, in _retry
    return func(*args, **kw)
  File "/var/task/botocore/client.py", line 316, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/var/task/botocore/client.py", line 635, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the DescribeElasticsearchDomains operation: Please provide a maximum of 5 Elasticsearch domain names to describe.
```
 - `custodian version --debug` output

**Additional context**
Seems to be introduced with 0.9.2.0



Discussion:

Resolving patch:
diff --git a/c7n/resources/elasticsearch.py b/c7n/resources/elasticsearch.py
--- a/c7n/resources/elasticsearch.py
+++ b/c7n/resources/elasticsearch.py
@@ -18,7 +18,7 @@
 from c7n.filters.vpc import SecurityGroupFilter, SubnetFilter, VpcFilter
 from c7n.manager import resources
 from c7n.query import ConfigSource, DescribeSource, QueryResourceManager, TypeInfo
-from c7n.utils import local_session, type_schema
+from c7n.utils import chunks, local_session, type_schema
 from c7n.tags import Tag, RemoveTag, TagActionFilter, TagDelayedAction
 
 from .securityhub import PostFinding
@@ -34,6 +34,7 @@ def get_resources(self, resource_ids):
     def augment(self, domains):
         client = local_session(self.manager.session_factory).client('es')
         model = self.manager.get_model()
+        results = []
 
         def _augment(resource_set):
             resources = self.manager.retry(
@@ -45,7 +46,10 @@ def _augment(resource_set):
                     client.list_tags, ARN=rarn).get('TagList', [])
             return resources
 
-        return _augment(domains)
+        for resource_set in chunks(domains, 5):
+            results.extend(_augment(resource_set))
+
+        return results
 
 
 @resources.register('elasticsearch')


Test patch: