[AWS] Set max results if its not set

* If max results is not set and instance IDs are not provided for the
  describe instances call in the aws cloud provider, set max results.
* This prevents an expensive call against the EC2 API, which can
  result in timeouts.
This commit is contained in:
Nick Turner 2021-11-09 18:50:19 +00:00
parent 6ac2d8edc8
commit 98f26a2731

View File

@ -960,6 +960,13 @@ func (s *awsSdkEC2) DescribeInstances(request *ec2.DescribeInstancesInput) ([]*e
results := []*ec2.Instance{}
var nextToken *string
requestTime := time.Now()
if request.MaxResults == nil && request.InstanceIds == nil {
// MaxResults must be set in order for pagination to work
// MaxResults cannot be set with InstanceIds
request.MaxResults = aws.Int64(1000)
}
for {
response, err := s.ec2.DescribeInstances(request)
if err != nil {