diff --git a/README.md b/README.md index ec64cab2a23..2f6e04b61f0 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,8 @@ The following settings are supported: * `bucket`: The name of the bucket to be used for snapshots. (Mandatory) * `region`: The region where bucket is located. Defaults to US Standard +* `endpoint`: The endpoint to the S3 API. Defaults to AWS's default S3 endpoint. Note that setting a region overrides the endpoint setting. +* `protocol`: The protocol to use (`http` or `https`). Defaults to `https`. * `base_path`: Specifies the path within bucket to repository data. Defaults to root directory. * `access_key`: The access key to use for authentication. Defaults to value of `cloud.aws.access_key`. * `secret_key`: The secret key to use for authentication. Defaults to value of `cloud.aws.secret_key`. @@ -289,10 +291,16 @@ repositories: remote-bucket: bucket: region: + external-bucket: + bucket: + access_key: + secret_key: + endpoint: + protocol: ``` -Replace all occurrences of `access_key`, `secret_key`, `bucket` and `region` with your settings. Please, note that the test will delete all snapshot/restore related files in the specified buckets. +Replace all occurrences of `access_key`, `secret_key`, `endpoint`, `protocol`, `bucket` and `region` with your settings. Please, note that the test will delete all snapshot/restore related files in the specified buckets. To run test: diff --git a/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java b/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java index fb01a0b9705..e5db2ed7357 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.component.LifecycleComponent; public interface AwsS3Service extends LifecycleComponent { AmazonS3 client(); - AmazonS3 client(String region, String account, String key); + AmazonS3 client(String endpoint, String protocol, String region, String account, String key); - AmazonS3 client(String region, String account, String key, Integer maxRetries); + AmazonS3 client(String endpoint, String protocol, String region, String account, String key, Integer maxRetries); } diff --git a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index a5828e40e0a..076c0f308e7 100644 --- a/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -60,33 +60,32 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent clientDescriptor = new Tuple(endpoint, account); AmazonS3Client client = clients.get(clientDescriptor); if (client != null) { @@ -94,8 +93,10 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent creating s3 repostoriy with endpoint [{}], bucket[{}] and path [{}]", bucketSettings.get("endpoint"), bucketSettings.get("bucket"), basePath); + PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo") + .setType("s3").setSettings(ImmutableSettings.settingsBuilder() + .put("protocol", bucketSettings.get("protocol")) + .put("endpoint", bucketSettings.get("endpoint")) + .put("access_key", bucketSettings.get("access_key")) + .put("secret_key", bucketSettings.get("secret_key")) + ).get(); + assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); + assertRepositoryIsOperational(client, "test-repo"); + } + /** * This test verifies that the test configuration is set up in a manner that * does not make the test {@link #testRepositoryInRemoteRegion()} pointless. @@ -430,6 +448,8 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTest { settings.getByPrefix("repositories.s3.remote-bucket.") }; for (Settings bucket : buckets) { + String endpoint = bucket.get("endpoint", settings.get("repositories.s3.endpoint")); + String protocol = bucket.get("protocol", settings.get("repositories.s3.protocol")); String region = bucket.get("region", settings.get("repositories.s3.region")); String accessKey = bucket.get("access_key", settings.get("cloud.aws.access_key")); String secretKey = bucket.get("secret_key", settings.get("cloud.aws.secret_key")); @@ -438,7 +458,7 @@ abstract public class AbstractS3SnapshotRestoreTest extends AbstractAwsTest { // We check that settings has been set in elasticsearch.yml integration test file // as described in README assertThat("Your settings in elasticsearch.yml are incorrects. Check README file.", bucketName, notNullValue()); - AmazonS3 client = internalCluster().getInstance(AwsS3Service.class).client(region, accessKey, secretKey); + AmazonS3 client = internalCluster().getInstance(AwsS3Service.class).client(endpoint, protocol, region, accessKey, secretKey); try { ObjectListing prevListing = null; //From http://docs.amazonwebservices.com/AmazonS3/latest/dev/DeletingMultipleObjectsUsingJava.html