0

In the previous version of AWS SDK there were many handy functions like getDescribeInstancesIterator which would return an array iterator for results (in this case an array of instances matching the filters).

This function (and similar) have been removed in the new AWS SDK. After some research I can find instead is a getIterator($name, array $args = []) function defined as an AwsClientTrait.

I'm unsure how I can use this new getIterator function to replace the getDescribeInstancesIterator function, i.e. to get an Array iterator for describeInstances function that returns list of matching instances like before (without having to worry about pagination, etc)?

Any code sample would be extremely useful.

supersan
  • 5,671
  • 3
  • 45
  • 64

1 Answers1

0

Finally figured it out. The new syntax is like this

$ec2Client->getIterator('FunctionName', 'Values')

So getDescribeInstancesIterator now becomes:

$ec2Client->getIterator('DescribeInstances', [...'Filters'])

This syntax is same for all operations including iterating over files in buckets, getting running instances, etc.

supersan
  • 5,671
  • 3
  • 45
  • 64