Jun 26, 2015

AWS - Extract protected API response data.

In most AWS API call you will get response model.

object(Guzzle\Service\Resource\Model)#97 (2) {
  ["structure":protected]=>
  NULL
  ["data":protected]=> Array(THE DATA YOU NEED TO ACCESS HERE)
}

Here my sample, call to describe the ec2 instance.

$result = $client->describeInstances();

var_dump($result); // Display the result in Guzzle\Service\Resource\Model

$response = $result->toArray(); // Convert the protected data, into array

// Display the intance IP information.
var_dump($response['Reservations'][0]['Instances'][0]['NetworkInterfaces'][0]['PrivateIpAddresses']);
Reference Stackoverflow.com