Amazon Elastic Compute Cloud
User Guide (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Using Regions and Availability Zones

This section describes how to work with Regions and Availability Zones.

[Note]Note

Data transfer between Regions is charged at the Internet data transfer rate for both the sending and the receiving Region. For detailed information on Amazon EC2 charges, go to the Amazon EC2 Product Page.

Region and Availability Zone Concepts

Amazon EC2 provides the ability to place instances in multiple locations. Amazon EC2 locations are composed of Availability Zones and Regions. Regions are dispersed and located in separate geographic areas (US, EU, etc.). Availability Zones are distinct locations within a Region that are engineered to be isolated 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 Regions, you can design your application to be closer to specific customers or to meet legal or other requirements. By launching instances in separate Availability Zones, you can protect your applications from the failure of a single location.

The following graphic shows a representation of Amazon EC2. Each Region is completely independent. Each Availability Zone is isolated, but connected through low-latency links.

Regions and Availability Zones

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.

To launch or work with instances, you must specify the correct Region URL endpoint. For example, to access the US-East Region (default), you make service calls to the ec2.us-east-1.amazonaws.com service endpoint.

For information about this product's regions and endpoints, go to Regions and Endpoints in the Amazon Web Services General Reference.

Availability Zones

Amazon operates state-of-the-art, highly available data center facilities. However, failures can occur that affect the availability of instances that are in the same location. Although this is rare, if you host all your Amazon EC2 instances in a single location that is affected by such a failure, your instances will be unavailable.

For example, if you have instances distributed across three Availability Zones and one of the instances fails, you can design your application so the instances in the remaining Availability Zones handle any requests.

[Note]Note

You can use Availability Zones in conjunction with elastic IP addresses to remap IP addresses across Availability Zones. For information on elastic IP addresses, see Elastic IP Addresses Concepts.

API and Command Overview

The following table summarizes the available Region and Availability Zone commands and corresponding API actions. For more information about the commands, go to the Amazon Elastic Compute Cloud Command Line Reference. For more information about the API actions, go to the Amazon Elastic Compute Cloud API Reference.

Command and API ActionDescription

ec2-describe-availability-zones

DescribeAvailabilityZones

Lists Availability Zones available to your account

ec2-describe-regions

DescribeRegions

Lists Regions available to your account

Describing Regions and Availability Zones

This section describes how to determine which Regions and Availability Zones are available.

AWS Management Console

To find Regions and Availability Zones

  1. Log in to the AWS Management Console and click the Amazon EC2 tab.

  2. To determine available Regions, select the Region list box in the Navigation pane.

    After selecting a Region, you can view Availability Zones within that Region when launching an instance or creating a new Amazon EBS volume.

  3. To view Availability Zones within a Region, click Volumes in the Navigation pane.

    The Create Volume dialog box appears.

  4. To view Availability Zones within the Region, select the Availability Zones list box.

  5. When you are finished, click Cancel.

Command Line Tools

To find Regions

  • Enter the following command to describe Regions:

    PROMPT> ec2-describe-regions
    REGION  ap-northeast-1       ec2.ap-northeast-1.amazonaws.com
    REGION  ap-southeast-1       ec2.ap-southeast-1.amazonaws.com
    ..

To find Availability Zones

  • Enter the following command to describe Availability Zones within the us-east-1 Region:

    PROMPT> ec2-describe-availability-zones --region us-east-1

    Amazon EC2 returns output similar to the following:

    AVAILABILITYZONE        us-east-1a      available       us-east-1
    AVAILABILITYZONE        us-east-1b      available       us-east-1
    AVAILABILITYZONE        us-east-1c      available       us-east-1
    AVAILABILITYZONE        us-east-1d      available       us-east-1

API

To find Regions

  • Construct the following Query request.

    https://ec2.amazonaws.com/
    ?Action=DescribeRegions
    &...auth parameters...

    Following is an example response.

    <DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
      <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
      <regionInfo>
        <item>
          <regionName>us-east-1</regionName>
          <regionEndpoint>ec2.us-east-1.amazonaws.com</regionEndpoint>
        </item>
        <item>
          <regionName>eu-west-1</regionName>
          <regionEndpoint>ec2.eu-west-1.amazonaws.com</regionEndpoint>
        </item>
      </regionInfo>
    </DescribeRegionsResponse>

To find Availability Zones

  • Construct the following Query request.

    https://ec2.amazonaws.com/
    ?Action=DescribeAvailabilityZones
    &...auth parameters...

    Following is an example response.

    <DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2011-12-15/">
      <requestId>35a9e5f3-4ed2-4cc2-a616-482b71c82c76</requestId>
          <availabilityZoneInfo>
            <item>
              <zoneName>us-east-1a</zoneName>
              <zoneState>available</zoneState>
              <regionName>us-east-1</regionName>
              <messageSet/>
            </item>
            <item>
              <zoneName>us-east-1b</zoneName>
              <zoneState>available</zoneState>
              <regionName>us-east-1</regionName>
              <messageSet/>
            </item>
            <item>
              <zoneName>us-east-1c</zoneName>
              <zoneState>available</zoneState>
              <regionName>us-east-1</regionName>
              <messageSet/>
            </item>
            <item>
              <zoneName>us-east-1d</zoneName>
              <zoneState>available</zoneState>
              <regionName>us-east-1</regionName>
              <messageSet/>
            </item>
          </availabilityZoneInfo>
    </DescribeAvailabilityZonesResponse>

Specifying the Region to Use

Every command or call you make to EC2 must target a specific Region. This section explains how to specify the Region you want to use.

[Note]Note

The ec2.us-west-1.amazonaws.com Region is the original Amazon EC2 Region and is selected by default.

AWS Management Console

To specify the Region

  • Use the Region selector in the top left corner of the page.

    Region selection in the console

Command Line Tools

To specify the Region

  • Change the EC2_URL environment variable's value to the Region's endpoint (e.g., https://ec2.us-west-1.amazonaws.com).

    [Tip]Tip

    You can also use the --region command line option (e.g., --region us-west-1), or override the URL endpoint using the -U flag (e.g., -U https://ec2.us-west-1.amazonaws.com).

API

To specify the Region

  • Configure your application to use the Region's endpoint (e.g., https://ec2.us-west-1.amazonaws.com).

Launching Instances in a Specific Availability Zone

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.

[Note]Note

Availability Zones are not the same across accounts. The Availability Zone us-east-1a for account A is not necessarily the same as us-east-1a for account B. Zone assignments are mapped independently for each account.

You are charged a small bandwidth charge for data that crosses Availability Zones. For more information, go to the Amazon EC2 product page.

AWS Management Console

To launch an instance in a specific Availability Zone

  • On the Instance Details page of the instance launch wizard, you can specify the Availability Zone of your choice, or specify no preference.

    Selecting an Availability Zone when launching an instance in the console

Command Line Tools

To launch an instance in a specific Availability Zone

  • Specify the Availability Zone you want to launch the instances into using the --availability-zone option.

    PROMPT> ec2-run-instances ami_id -n count --availability-zone zone 

    Amazon EC2 returns output similar to the following:

    RESERVATION r-0ea54067 999988887777 default
    INSTANCE	i-cfd732a6	ami-6ba54002	pending	0	m1.small	2010-03-19T13:59:03+0000	us-east-1a	aki-94c527fd	ari-96c527ff	monitoring-disabled		ebs
    INSTANCE	i-cfd732a7	ami-6ba54002	pending	1	m1.small	2010-03-19T13:59:03+0000	us-east-1a	aki-94c527fd	ari-96c527ff	monitoring-disabled		ebs
    INSTANCE	i-cfd732a8	ami-6ba54002	pending	2	m1.small	2010-03-19T13:59:03+0000	us-east-1a	aki-94c527fd	ari-96c527ff	monitoring-disabled		ebs
    INSTANCE	i-cfd732a9	ami-6ba54002	pending	3	m1.small	2010-03-19T13:59:03+0000	us-east-1a	aki-94c527fd	ari-96c527ff	monitoring-disabled		ebs

API

To launch an instance in a specific Availability Zone

  • Construct the following Query request.

    https://ec2.amazonaws.com/
    ?Action=RunInstances
    &ImageId=ami-id
    &MaxCount=1
    &MinCount=1
    &KeyName=keypair-name
    &Placement.AvailabilityZone=zone
    &...auth parameters...