get_console_output ( $instance_id, $opt )

The GetConsoleOutput operation retrieves console output for the specified instance.

Instance console output is buffered and posted shortly after instance boot, reboot, and termination. Amazon EC2 preserves the most recent 64 KB output which will be available for at least one hour after the most recent post.

Access

public

Parameters

Parameter

Type

Required

Description

$instance_id

string

Required

The ID of the instance for which you want console output.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This is useful for manually-managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response. The value of output is automatically Base64-decoded.

Examples

Get the EC2 console output.

// Instantiate the class
$ec2 = new AmazonEC2();

// Get console output
$response = $ec2->get_console_output('i-1f549375');

// Success?
var_dump($response->isOK());
Result:
bool(true)

Source

Method defined in services/ec2.class.php | Toggle source view (15 lines) | View on GitHub

public function get_console_output($instance_id, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['InstanceId'] = $instance_id;

    $response = $this->authenticate('GetConsoleOutput', $opt, $this->hostname);

    // Automatically Base64-decode the <output> value.
    if ($this->util->is_base64((string) $response->body->output))
    {
        $response->body->output = base64_decode($response->body->output);
    }

    return $response;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback