Using regions and availability zones for Amazon EC2 with AWS SDK for PHP Version 3 - AWS SDK for PHP
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Using regions and availability zones for Amazon EC2 with AWS SDK for PHP Version 3

Amazon EC2 is hosted in multiple locations worldwide. These locations are composed of AWS Regions and Availability Zones. Each Region is a separate geographic area, with multiple isolated locations known as Availability Zones. Amazon EC2 provides the ability to place instances and data in multiple locations.

The following examples show how to:

All the example code for the AWS SDK for PHP is available here on GitHub.

Credentials

Before running the example code, configure your AWS credentials, as described in Authenticating with AWS using AWS SDK for PHP Version 3. Then import the AWS SDK for PHP, as described in Installing the AWS SDK for PHP Version 3.

Describe availability zones

Imports

require 'vendor/autoload.php';

Sample Code

$ec2Client = new Aws\Ec2\Ec2Client([ 'region' => 'us-west-2', 'version' => '2016-11-15', 'profile' => 'default' ]); $result = $ec2Client->describeAvailabilityZones(); var_dump($result);

Describe regions

Imports

require 'vendor/autoload.php';

Sample Code

$ec2Client = new Aws\Ec2\Ec2Client([ 'region' => 'us-west-2', 'version' => '2016-11-15', 'profile' => 'default' ]); $result = $ec2Client->describeRegions(); var_dump($result);