User guide

AmazonEC2 ec2 = new AmazonEC2(myCredentials);
ec2.setRegion(Region.getRegion(Regions.US_WEST_2));
Important
AmazonWebServiceClient.setRegion is not thread-safe, so you should be careful when
changing the region for an existing client.To avoid potential thread synchronization issues,
create a new client object for each region that you are using.
Choosing a Specific Endpoint
Each AWS client can be configured to use a specific endpoint by calling the setEndpoint method.
For example, to configure the Amazon EC2 client to use the EU (Ireland) region, use the following code:
AmazonEC2 ec2 = new AmazonEC2(myCredentials);
ec2.setEndpoint("https://ec2.eu-west-1.amazonaws.com");
Go to Regions and Endpoints for the current list of regions and their corresponding endpoints for all AWS
services.
Developing Code that Accesses Multiple AWS
Regions
Regions are logically isolated from each other. For example, you can't access US East resources when
communicating with the EU West endpoint. If your code accesses multiple AWS regions, instantiate a
specific client for each region, as the following example shows.
AmazonEC2 ec2_euro = Region.getRegion(Regions.EU_WEST_1).createClient(
AmazonEC2Client.class, credentials, clientConfig);
AmazonEC2 ec2_us = Region.getRegion(Regions.US_EAST_1).createClient(
AmazonEC2Client.class, credentials, clientConfig);
Client Networking Configuration
The AWS SDK for Java allows you to change the default client configuration, which is helpful when you
want to:
Connect to the Internet through proxy
Change HTTP transport settings, such as connection timeout and request retries.
Specify TCP socket buffer size hints
Proxy Configuration
When constructing a client object, you can pass in an optional com.amazonaws.ClientConfiguration
object to customize the client's configuration.
Version v1.0.0
14
AWS SDK for Java Developer Guide
Choosing a Specific Endpoint