Skip to content

Commit

Permalink
Wrong endpoint for cn-north-1
Browse files Browse the repository at this point in the history
Commit ea9609c does not work as expected.

China is not part of the [S3 regions](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) but part of [Isolated Regions](http://docs.aws.amazon.com/general/latest/gr/isolated_regions.html).

The patch uses for S3 `s3-cn-north-1.amazonaws.com` which is wrong because in that case the end point is `s3.cn-north-1.amazonaws.com.cn`.
Same goes for EC2 which was `ec2.cn-north-1.amazonaws.com` but should be `ec2.cn-north-1.amazonaws.com.cn`.

Related documentation:

* http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
* http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
* http://docs.aws.amazon.com/general/latest/gr/isolated_regions.html

Closing #156
(cherry picked from commit 491a59b)
(cherry picked from commit f12cacc)
  • Loading branch information
dadoonet committed Feb 19, 2015
1 parent c7187f2 commit 4c02a01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
Expand Up @@ -126,7 +126,7 @@ public synchronized AmazonEC2 client() {
} else if (region.equals("sa-east") || region.equals("sa-east-1")) {
endpoint = "ec2.sa-east-1.amazonaws.com";
} else if (region.equals("cn-north") || region.equals("cn-north-1")) {
endpoint = "ec2.cn-north-1.amazonaws.com";
endpoint = "ec2.cn-north-1.amazonaws.com.cn";
} else {
throw new ElasticsearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
}
Expand Down
Expand Up @@ -159,42 +159,26 @@ private String getDefaultEndpoint() {
}

private static String getEndpoint(String region) {
if ("us-east".equals(region)) {
if ("us-east".equals(region) || "us-east-1".equals(region)) {
return "s3.amazonaws.com";
} else if ("us-east-1".equals(region)) {
return "s3.amazonaws.com";
} else if ("us-west".equals(region)) {
return "s3-us-west-1.amazonaws.com";
} else if ("us-west-1".equals(region)) {
} else if ("us-west".equals(region) || "us-west-1".equals(region)) {
return "s3-us-west-1.amazonaws.com";
} else if ("us-west-2".equals(region)) {
return "s3-us-west-2.amazonaws.com";
} else if ("ap-southeast".equals(region)) {
return "s3-ap-southeast-1.amazonaws.com";
} else if ("ap-southeast-1".equals(region)) {
} else if ("ap-southeast".equals(region) || "ap-southeast-1".equals(region)) {
return "s3-ap-southeast-1.amazonaws.com";
} else if ("ap-southeast-2".equals(region)) {
return "s3-ap-southeast-2.amazonaws.com";
} else if ("ap-northeast".equals(region)) {
return "s3-ap-northeast-1.amazonaws.com";
} else if ("ap-northeast-1".equals(region)) {
} else if ("ap-northeast".equals(region) || "ap-northeast-1".equals(region)) {
return "s3-ap-northeast-1.amazonaws.com";
} else if ("eu-west".equals(region)) {
} else if ("eu-west".equals(region) || "eu-west-1".equals(region)) {
return "s3-eu-west-1.amazonaws.com";
} else if ("eu-west-1".equals(region)) {
return "s3-eu-west-1.amazonaws.com";
} else if ("eu-central".equals(region)) {
return "s3.eu-central-1.amazonaws.com";
} else if ("eu-central-1".equals(region)) {
} else if ("eu-central".equals(region) || "eu-central-1".equals(region)) {
return "s3.eu-central-1.amazonaws.com";
} else if ("sa-east".equals(region)) {
return "s3-sa-east-1.amazonaws.com";
} else if ("sa-east-1".equals(region)) {
} else if ("sa-east".equals(region) || "sa-east-1".equals(region)) {
return "s3-sa-east-1.amazonaws.com";
} else if ("cn-north".equals(region)) {
return "s3-cn-north-1.amazonaws.com";
} else if ("cn-north-1".equals(region)) {
return "s3-cn-north-1.amazonaws.com";
} else if ("cn-north".equals(region) || "cn-north-1".equals(region)) {
return "s3.cn-north-1.amazonaws.com.cn";
} else {
throw new ElasticsearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
}
Expand Down

0 comments on commit 4c02a01

Please sign in to comment.