Skip to content

Commit ea9609c

Browse files
committed
Add China region for s3 and ec2
China region name is `cn-north-1`. Closes #156.
1 parent a76e935 commit ea9609c

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ The `cloud.aws.region` can be set to a region and will automatically use the rel
8585
* `ap-northeast` (`ap-northeast-1`)
8686
* `eu-west` (`eu-west-1`)
8787
* `eu-central` (`eu-central-1`)
88-
* `sa-east` (`sa-east-1`).
89-
88+
* `sa-east` (`sa-east-1`)
89+
* `cn-north` (`cn-north-1`)
9090

9191
## EC2 Discovery
9292

src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ public synchronized AmazonEC2 client() {
125125
endpoint = "ec2.eu-central-1.amazonaws.com";
126126
} else if (region.equals("sa-east") || region.equals("sa-east-1")) {
127127
endpoint = "ec2.sa-east-1.amazonaws.com";
128+
} else if (region.equals("cn-north") || region.equals("cn-north-1")) {
129+
endpoint = "ec2.cn-north-1.amazonaws.com";
128130
} else {
129131
throw new ElasticsearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
130132
}

src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ private static String getEndpoint(String region) {
191191
return "s3-sa-east-1.amazonaws.com";
192192
} else if ("sa-east-1".equals(region)) {
193193
return "s3-sa-east-1.amazonaws.com";
194+
} else if ("cn-north".equals(region)) {
195+
return "s3-cn-north-1.amazonaws.com";
196+
} else if ("cn-north-1".equals(region)) {
197+
return "s3-cn-north-1.amazonaws.com";
194198
} else {
195199
throw new ElasticsearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
196200
}

src/main/java/org/elasticsearch/repositories/s3/S3Repository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ public S3Repository(RepositoryName name, RepositorySettings repositorySettings,
121121
region = "sa-east-1";
122122
} else if ("sa-east-1".equals(regionSetting)) {
123123
region = "sa-east-1";
124+
} else if ("cn-north".equals(regionSetting)) {
125+
region = "cn-north-1";
126+
} else if ("cn-north-1".equals(regionSetting)) {
127+
region = "cn-north-1";
124128
}
125129
}
126130
}

0 commit comments

Comments
 (0)