Zend_Service_Amazon_Ec2: Keypairs

Zend_Service_Amazon_Ec2: Regions and Availability Zones

Amazon EC2 provides the ability to place instances in different regions and Availability Zones. Regions are dispersed in separate geographic areas or countries. Availability Zones are located within regions and are engineered to be insulated from failures in other Availability Zones and provide inexpensive low latency network connectivity to other Availability Zones in the same region. By launching instances in separate Availability Zones, you can protect your applications from the failure of a single Availability Zone.

Amazon EC2 Regions

Amazon EC2 provides multiple regions so you can launch Amazon EC2 instances in locations that meet your requirements. For example, you might want to launch instances in Europe to be closer to your European customers or to meet legal requirements.

Each Amazon EC2 region is designed to be completely isolated from the other Amazon EC2 regions. This achieves the greatest possible failure independence and stability, and it makes the locality of each EC2 resource unambiguous.

Example #1 Viewing the available regions

describe is used to find out which regions your account has access to.

describe will return an array containing information about which regions are available. Each array will contain regionName and regionUrl.

  1. $ec2_region = new Zend_Service_Amazon_Ec2_Region('aws_key','aws_secret_key');
  2. $regions = $ec2_region->describe();
  3.  
  4. foreach($regions as $region) {
  5.     print $region['regionName'] . ' -- ' . $region['regionUrl'] . '<br />';
  6. }

Amazon EC2 Availability Zones

When you launch an instance, you can optionally specify an Availability Zone. If you do not specify an Availability Zone, Amazon EC2 selects one for you in the region that you are using. When launching your initial instances, we recommend accepting the default Availability Zone, which allows Amazon EC2 to select the best Availability Zone for you based on system health and available capacity. Even if you have other instances running, you might consider not specifying an Availability Zone if your new instances do not need to be close to, or separated from, your existing instances.

Example #2 Viewing the available zones

describe is used to find out which what the status is of each availability zone.

describe will return an array containing information about which zones are available. Each array will contain zoneName and zoneState.

  1. $ec2_zones = new Zend_Service_Amazon_Ec2_Availabilityzones('aws_key',
  2.                                                            'aws_secret_key');
  3. $zones = $ec2_zones->describe();
  4.  
  5. foreach($zones as $zone) {
  6.     print $zone['zoneName'] . ' -- ' . $zone['zoneState'] . '<br />';
  7. }

Zend_Service_Amazon_Ec2: Keypairs