From 0474a1bfea19859a92831a71bb5da62b1f290c62 Mon Sep 17 00:00:00 2001 From: bitsofinfo Date: Tue, 8 Jul 2014 20:32:13 -0400 Subject: [PATCH] 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. --- README.md | 17 +++++++++ .../cloud/aws/AwsEc2Service.java | 1 + .../cloud/aws/InternalAwsS3Service.java | 1 + ...ava => S3SnapshotRestoreAbstractTest.java} | 2 +- .../s3/S3SnapshotRestoreOverHttpTest.java | 35 +++++++++++++++++++ .../s3/S3SnapshotRestoreOverHttpsTest.java | 35 +++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) rename src/test/java/org/elasticsearch/repositories/s3/{S3SnapshotRestoreTest.java => S3SnapshotRestoreAbstractTest.java} (99%) create mode 100644 src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreOverHttpTest.java create mode 100644 src/test/java/org/elasticsearch/repositories/s3/S3SnapshotRestoreOverHttpsTest.java diff --git a/README.md b/README.md index d7232a7a240..76440f6b6b1 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java index 69829febdc8..6499ee0e29f 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java @@ -61,6 +61,7 @@ public class AwsEc2Service extends AbstractLifecycleComponent { 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)) { diff --git a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index 9cf215807f0..94ec05c1c44 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -89,6 +89,7 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent