set_hostname ( $hostname, $port_number )

Set the hostname to connect to. This is useful for alternate services that are API-compatible with AWS, but run from a different hostname.

Access

public

Parameters

Parameter

Type

Required

Description

$hostname

string

Required

The alternate hostname to use in place of the default one. Useful for mock or test applications living on different hostnames.

$port_number

integer

Optional

The alternate port number to use in place of the default one. Useful for mock or test applications living on different port numbers.

Returns

Type

Description

$this

A reference to the current instance.

Examples

Configure hostname and resource prefix.

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

// Point to the new endpoint
$ec2->set_hostname('localhost', '3000');
$ec2->set_resource_prefix('/services/mock');
$ec2->allow_hostname_override(false);

// Describe images
$response = $ec2->describe_images();

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

Source

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

public function set_hostname($hostname, $port_number = null)
{
    if ($this->override_hostname)
    {
        $this->hostname = $hostname;

        if ($port_number)
        {
            $this->port_number = $port_number;
            $this->hostname .= ':' . (string) $this->port_number;
        }
    }

    return $this;
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback