Sep 26, 2018

[HDGEM] How to set a Region in AWS SDK for Java

You can specify a region name and the SDK will automatically choose an appropriate endpoint for you. 

To explicitly set a region, we recommend that you use the Regions enum. This is an enumeration of all publicly available regions. To create a client with a region from the enum, use the following code.
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard()                      .withRegion(Regions.US_WEST_2)                      .build();  
If the region you are attempting to use isn't in the Regions enum, you can set the region using a string that represents the name of the region.
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard()                      .withRegion("us-west-2")                      .build();

Posted By Blogger to HDGEM at 5/04/2017 04:29:00 PM