From 23550f277b3aa6422c43970b8938cfb872c07658 Mon Sep 17 00:00:00 2001 From: Alexander Kazakov Date: Sun, 4 Dec 2016 20:02:05 +0300 Subject: [PATCH] Add us-east-2 AWS region --- docs/plugins/discovery-ec2.asciidoc | 3 +- docs/plugins/repository-s3.asciidoc | 3 +- .../cloud/aws/AwsEc2ServiceImpl.java | 4 + .../cloud/aws/InternalAwsS3Service.java | 86 +++++++++++++------ 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/docs/plugins/discovery-ec2.asciidoc b/docs/plugins/discovery-ec2.asciidoc index 474e4f587e3..751f76f82dc 100644 --- a/docs/plugins/discovery-ec2.asciidoc +++ b/docs/plugins/discovery-ec2.asciidoc @@ -111,9 +111,10 @@ The `cloud.aws.region` can be set to a region and will automatically use the rel The available values are: * `us-east` (`us-east-1`) for US East (N. Virginia) +* `us-east-2` for US East (Ohio) * `us-west` (`us-west-1`) for US West (N. California) * `us-west-2` for US West (Oregon) -* `ap-south-1` for Asia Pacific (Mumbai) +* `ap-south` (`ap-south-1`) for Asia Pacific (Mumbai) * `ap-southeast` (`ap-southeast-1`) for Asia Pacific (Singapore) * `ap-southeast-2` for Asia Pacific (Sydney) * `ap-northeast` (`ap-northeast-1`) for Asia Pacific (Tokyo) diff --git a/docs/plugins/repository-s3.asciidoc b/docs/plugins/repository-s3.asciidoc index 46789cf3f6e..7b56c56b199 100644 --- a/docs/plugins/repository-s3.asciidoc +++ b/docs/plugins/repository-s3.asciidoc @@ -116,9 +116,10 @@ You can specifically set it for s3 only using `cloud.aws.s3.region`. The available values are: * `us-east` (`us-east-1`) for US East (N. Virginia) +* `us-east-2` for US East (Ohio) * `us-west` (`us-west-1`) for US West (N. California) * `us-west-2` for US West (Oregon) -* `ap-south-1` for Asia Pacific (Mumbai) +* `ap-south` (`ap-south-1`) for Asia Pacific (Mumbai) * `ap-southeast` (`ap-southeast-1`) for Asia Pacific (Singapore) * `ap-southeast-2` for Asia Pacific (Sydney) * `ap-northeast` (`ap-northeast-1`) for Asia Pacific (Tokyo) diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java index 07f1c4f3c19..13d90c260e3 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java @@ -141,6 +141,9 @@ public class AwsEc2ServiceImpl extends AbstractComponent implements AwsEc2Servic case "us-east": endpoint = "ec2.us-east-1.amazonaws.com"; break; + case "us-east-2": + endpoint = "ec2.us-east-2.amazonaws.com"; + break; case "us-west": case "us-west-1": endpoint = "ec2.us-west-1.amazonaws.com"; @@ -152,6 +155,7 @@ public class AwsEc2ServiceImpl extends AbstractComponent implements AwsEc2Servic case "ap-southeast-1": endpoint = "ec2.ap-southeast-1.amazonaws.com"; break; + case "ap-south": case "ap-south-1": endpoint = "ec2.ap-south-1.amazonaws.com"; break; diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index 5a8e83b33e6..f6803c33d9e 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -162,35 +162,65 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent implements } private static String getEndpoint(String region) { - if ("us-east".equals(region) || "us-east-1".equals(region)) { - return "s3.amazonaws.com"; - } 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 (region.equals("ap-south-1")) { - return "s3-ap-south-1.amazonaws.com"; - } 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) || "ap-northeast-1".equals(region)) { - return "s3-ap-northeast-1.amazonaws.com"; - } else if ("ap-northeast-2".equals(region)) { - return "s3-ap-northeast-2.amazonaws.com"; - } else if ("eu-west".equals(region) || "eu-west-1".equals(region)) { - return "s3-eu-west-1.amazonaws.com"; - } else if ("eu-central".equals(region) || "eu-central-1".equals(region)) { - return "s3.eu-central-1.amazonaws.com"; - } else if ("sa-east".equals(region) || "sa-east-1".equals(region)) { - return "s3-sa-east-1.amazonaws.com"; - } else if ("cn-north".equals(region) || "cn-north-1".equals(region)) { - return "s3.cn-north-1.amazonaws.com.cn"; - } else if ("us-gov-west".equals(region) || "us-gov-west-1".equals(region)) { - return "s3-us-gov-west-1.amazonaws.com"; - } else { - throw new IllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]"); + final String endpoint; + switch (region) { + case "us-east": + case "us-east-1": + endpoint = "s3.amazonaws.com"; + break; + case "us-east-2": + endpoint = "s3.us-east-2.amazonaws.com"; + break; + case "us-west": + case "us-west-1": + endpoint = "s3-us-west-1.amazonaws.com"; + break; + case "us-west-2": + endpoint = "s3-us-west-2.amazonaws.com"; + break; + case "ap-south": + case "ap-south-1": + endpoint = "s3-ap-south-1.amazonaws.com"; + break; + case "ap-southeast": + case "ap-southeast-1": + endpoint = "s3-ap-southeast-1.amazonaws.com"; + break; + case "ap-southeast-2": + endpoint = "s3-ap-southeast-2.amazonaws.com"; + break; + case "ap-northeast": + case "ap-northeast-1": + endpoint = "s3-ap-northeast-1.amazonaws.com"; + break; + case "ap-northeast-2": + endpoint = "s3-ap-northeast-2.amazonaws.com"; + break; + case "eu-west": + case "eu-west-1": + endpoint = "s3-eu-west-1.amazonaws.com"; + break; + case "eu-central": + case "eu-central-1": + endpoint = "s3.eu-central-1.amazonaws.com"; + break; + case "sa-east": + case "sa-east-1": + endpoint = "s3-sa-east-1.amazonaws.com"; + break; + case "cn-north": + case "cn-north-1": + endpoint = "s3.cn-north-1.amazonaws.com.cn"; + break; + case "us-gov-west": + case "us-gov-west-1": + endpoint = "s3-us-gov-west-1.amazonaws.com"; + break; + default: + throw new IllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]"); } + + return endpoint; } @Override