Using Regions and Availability Zones
Topics
This section describes how to work with regions and Availability Zones.
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. |
API Overview
This section provides a brief overview of each operation.
-
DescribeAvailabilityZones—Describes Availability Zones available to your account
-
DescribeRegions—Describes regions available to your account
Note | |
---|---|
Although the region and Availability Zone operation list is limited, you can specify a region or Availability Zone for many operations. For information about region and Availability Zone concepts, see Availability Zones. |
Describing Regions and Availability Zones
This section describes how to determine which regions and Availability Zones are available.
Procedure
To find regions
-
If you are using SOAP, construct the following request:
<DescribeRegions xmlns="http://ec2.amazonaws.com/doc/2009-04-04/"> <regionSet/> <DescribeRegions>
-
If you are using Query, construct the following request:
https://ec2.amazonaws.com/ ?Action=DescribeRegions &...auth parameters...
-
View output similar to the following:
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04//"> <regionInfo> <item> <regionName>us-east-1</regionName> <regionUrl>us-east-1.ec2.amazonaws.com</regionUrl> </item> <item> <regionName>eu-west-1</regionName> <regionUrl>eu-west-1.ec2.amazonaws.com</regionUrl> </item> </regionInfo> </DescribeRegionsResponse>
To find Availability Zones
-
If you are using SOAP, construct the following request:
<DescribeAvailabilityZones xmlns="http://ec2.amazonaws.com/doc/2009-04-04/"> <availabilityZoneSet/> <DescribeAvailabilityZones>
-
If you are using Query, construct the following request:
https://ec2.amazonaws.com/ ?Action=DescribeAvailabilityZones &...auth parameters...
-
View output similar to the following:
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04//"> <availabilityZoneInfo> <item> <zoneName>us-east-1a</zoneName> <zoneState>available</zoneState> </item> <item> <zoneName>us-east-1b</zoneName> <zoneState>available</zoneState> </item> <item> <zoneName>us-east-1c</zoneName> <zoneState>available</zoneState> </item> <item> <zoneName>us-east-1d</zoneName> <zoneState>available</zoneState> </item> </availabilityZoneInfo> </DescribeAvailabilityZonesResponse>
How to Configure Your Environment
After choosing a region and one or more Availability Zones, you should set up your environment.
Note | |
---|---|
The |
To set up your environment
-
If you are using the command line tools, change the
EC2_URL
environment variable to point to the correct region.Note You can also use the
--region
command line option, or override the URL endpoint using the-U
flag. -
If you are using the AWS Management Console, you do not need to take any steps.
-
If you are using APIs, configure your application to use the appropriate service endpoint.
Launching Instances in Specific 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.
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. |
Procedure
To launch an instance in a specific Availability Zone
-
If you are using SOAP, construct the following request:
<RunInstances xmlns="http://ec2.amazonaws.com/doc/2009-04-04/"> <imageId>
ami-id
</imageId> <minCount>1</minCount> <maxCount>1</maxCount> <keyName>keypair-name
</keyName> <groupSet/> <placement> <availabilityZone>zone
</availabilityZone> </placement> </RunInstances> -
If you are using Query, construct the following request:
https://ec2.amazonaws.com/ ?Action=RunInstances &ImageId=
ami-id
&MaxCount=1 &MinCount=1 &KeyName=keypair-name
&Placement.AvailabilityZone=zone
&...auth parameters... -
View output similar to the following:
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/"> <reservationId>r-47a5402e</reservationId> <ownerId>AIDADH4IGTRXXKCD</ownerId> <groupSet> <item> <groupId>default</groupId> </item> </groupSet> <instancesSet> <item> <instanceId>i-2ba64342</instanceId> <imageId>ami-60a54009</imageId> <instanceState> <code>0</code> <name>pending</name> </instanceState> <privateDnsName></privateDnsName> <dnsName></dnsName> <keyName>example-key-name</keyName> <amiLaunchIndex>0</amiLaunchIndex> <instanceType>m1.small</instanceType> <launchTime>2007-08-07T11:51:50.000Z</launchTime> <placement> <availabilityZone>us-east-1b</availabilityZone> </placement> </item> </instancesSet> </RunInstancesResponse>