Skip to content

Commit

Permalink
Allow https communication per ec2 or s3 service
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bitsofinfo authored and dadoonet committed Aug 5, 2014
1 parent f3a3262 commit 0474a1b
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Expand Up @@ -42,6 +42,23 @@ cloud:
secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
```

### Transport security

By default this plugin uses HTTP for all API calls to AWS endpoints. If you wish to configure HTTPS you can set
`cloud.aws.protocol` in the elasticsearch config. You can optionally override this setting per individual service
via: `cloud.aws.ec2.protocol` or `cloud.aws.s3.protocol`.

```
cloud:
aws:
protocol: http
s3:
protocol: https
ec2:
protocol: http
```

### Region

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:
Expand Down
Expand Up @@ -61,6 +61,7 @@ public synchronized AmazonEC2 client() {

ClientConfiguration clientConfiguration = new ClientConfiguration();
String protocol = componentSettings.get("protocol", "http").toLowerCase();
protocol = componentSettings.get("ec2.protocol", protocol).toLowerCase();
if ("http".equals(protocol)) {
clientConfiguration.setProtocol(Protocol.HTTP);
} else if ("https".equals(protocol)) {
Expand Down
Expand Up @@ -89,6 +89,7 @@ private synchronized AmazonS3 getClient(String endpoint, String account, String

ClientConfiguration clientConfiguration = new ClientConfiguration();
String protocol = componentSettings.get("protocol", "http").toLowerCase();
protocol = componentSettings.get("s3.protocol", protocol).toLowerCase();
if ("http".equals(protocol)) {
clientConfiguration.setProtocol(Protocol.HTTP);
} else if ("https".equals(protocol)) {
Expand Down
Expand Up @@ -55,7 +55,7 @@
*/
@AwsTest
@ClusterScope(scope = Scope.SUITE, numDataNodes = 2, numClientNodes = 0, transportClientRatio = 0.0)
public class S3SnapshotRestoreTest extends AbstractAwsTest {
abstract public class S3SnapshotRestoreAbstractTest extends AbstractAwsTest {

@Override
public Settings indexSettings() {
Expand Down
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch (the "Author") under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Author licenses this
* file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.repositories.s3;

import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;

/**
*/
public class S3SnapshotRestoreOverHttpTest extends S3SnapshotRestoreAbstractTest {
@Override
public Settings nodeSettings(int nodeOrdinal) {
ImmutableSettings.Builder settings = ImmutableSettings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put("cloud.aws.s3.protocol", "http");
return settings.build();
}
}
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch (the "Author") under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Author licenses this
* file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.repositories.s3;

import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;

/**
*/
public class S3SnapshotRestoreOverHttpsTest extends S3SnapshotRestoreAbstractTest {
@Override
public Settings nodeSettings(int nodeOrdinal) {
ImmutableSettings.Builder settings = ImmutableSettings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put("cloud.aws.s3.protocol", "https");
return settings.build();
}
}

0 comments on commit 0474a1b

Please sign in to comment.