Skip to content

Commit 0474a1b

Browse files
bitsofinfodadoonet
authored andcommitted
Allow https communication per ec2 or s3 service
By default all communication w/ AWS services done by this plugin is sent the clear over `http`, overriding amazons own default of https: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/ClientConfiguration.html#getProtocol() One has to set `cloud.aws.protocol` in `elasticsearch.yml` to force SSL. cloud.aws.protocol: https This is not entirely clear to the average user, and should be added to the documentation on both this project's README. Closes #101.
1 parent f3a3262 commit 0474a1b

File tree

6 files changed

+90
-1
lines changed

6 files changed

+90
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ cloud:
4242
secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
4343
```
4444

45+
### Transport security
46+
47+
By default this plugin uses HTTP for all API calls to AWS endpoints. If you wish to configure HTTPS you can set
48+
`cloud.aws.protocol` in the elasticsearch config. You can optionally override this setting per individual service
49+
via: `cloud.aws.ec2.protocol` or `cloud.aws.s3.protocol`.
50+
51+
```
52+
cloud:
53+
aws:
54+
protocol: http
55+
s3:
56+
protocol: https
57+
ec2:
58+
protocol: http
59+
60+
```
61+
4562
### Region
4663

4764
The `cloud.aws.region` can be set to a region and will automatically use the relevant settings for both `ec2` and `s3`. The available values are:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public synchronized AmazonEC2 client() {
6161

6262
ClientConfiguration clientConfiguration = new ClientConfiguration();
6363
String protocol = componentSettings.get("protocol", "http").toLowerCase();
64+
protocol = componentSettings.get("ec2.protocol", protocol).toLowerCase();
6465
if ("http".equals(protocol)) {
6566
clientConfiguration.setProtocol(Protocol.HTTP);
6667
} else if ("https".equals(protocol)) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private synchronized AmazonS3 getClient(String endpoint, String account, String
8989

9090
ClientConfiguration clientConfiguration = new ClientConfiguration();
9191
String protocol = componentSettings.get("protocol", "http").toLowerCase();
92+
protocol = componentSettings.get("s3.protocol", protocol).toLowerCase();
9293
if ("http".equals(protocol)) {
9394
clientConfiguration.setProtocol(Protocol.HTTP);
9495
} else if ("https".equals(protocol)) {

src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreTest.java renamed to src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreAbstractTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*/
5656
@AwsTest
5757
@ClusterScope(scope = Scope.SUITE, numDataNodes = 2, numClientNodes = 0, transportClientRatio = 0.0)
58-
public class S3SnapshotRestoreTest extends AbstractAwsTest {
58+
abstract public class S3SnapshotRestoreAbstractTest extends AbstractAwsTest {
5959

6060
@Override
6161
public Settings indexSettings() {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to Elasticsearch (the "Author") under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Author licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.repositories.s3;
21+
22+
import org.elasticsearch.common.settings.ImmutableSettings;
23+
import org.elasticsearch.common.settings.Settings;
24+
25+
/**
26+
*/
27+
public class S3SnapshotRestoreOverHttpTest extends S3SnapshotRestoreAbstractTest {
28+
@Override
29+
public Settings nodeSettings(int nodeOrdinal) {
30+
ImmutableSettings.Builder settings = ImmutableSettings.builder()
31+
.put(super.nodeSettings(nodeOrdinal))
32+
.put("cloud.aws.s3.protocol", "http");
33+
return settings.build();
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to Elasticsearch (the "Author") under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Author licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.repositories.s3;
21+
22+
import org.elasticsearch.common.settings.ImmutableSettings;
23+
import org.elasticsearch.common.settings.Settings;
24+
25+
/**
26+
*/
27+
public class S3SnapshotRestoreOverHttpsTest extends S3SnapshotRestoreAbstractTest {
28+
@Override
29+
public Settings nodeSettings(int nodeOrdinal) {
30+
ImmutableSettings.Builder settings = ImmutableSettings.builder()
31+
.put(super.nodeSettings(nodeOrdinal))
32+
.put("cloud.aws.s3.protocol", "https");
33+
return settings.build();
34+
}
35+
}

0 commit comments

Comments
 (0)