# TransportClient and creating an S3 snapshot repository

**URL:** <https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088>\
**Category:** Elasticsearch\
**Created:** [July 8, 2016, 7:22pm UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088 "2016-07-08T19:22:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![martiansnoop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martiansnoop/32/10809_2.png) [@martiansnoop](https://discuss.elastic.co/u/martiansnoop)\
**Post date:** [July 8, 2016, 7:22pm UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/1 "2016-07-08T19:22:04Z")

</div>

es version: 2.3.3

I'm currently attempting to create an s3 snapshot repository using the java TransportClient. I'm getting the following error:

```auto
RepositoryException[[028181cde20d44a8bb3009f71daf8524_backup] failed to create repository]; nested: IllegalArgumentException[Unknown [repository] type [S3]];
at org.elasticsearch.repositories.RepositoriesService.createRepositoryHolder(RepositoriesService.java:411)
[snip]
Caused by: java.lang.IllegalArgumentException: Unknown [repository] type [S3]
at org.elasticsearch.common.util.ExtensionPoint$SelectedType.bindType(ExtensionPoint.java:146)

```

I tried adding the cloud aws plugin to the transport client like this:

```auto
new TransportClient
                .Builder()
                .settings(Settings.builder().put("cluster.name", "cluster_name"))
                .addPlugin(CloudAwsPlugin.class)
                .build()

```

but I'm still getting the same error.

EDIT: Figured it out. needed to enable the plugin via the cloud.enabled setting

```auto
new TransportClient
                .Builder()
                .settings(Settings.builder().put("cluster.name", config.clusterName).put("cloud.enabled", true))
                .addPlugin(CloudAwsPlugin.class)
                .build()

```

also needed to set the type of my repo to "s3" instead of "S3". The capital S worked in es 1.7.4, but not in 2.3.3.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 9, 2016, 10:17am UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/2 "2016-07-09T10:17:49Z")

</div>

Thank you for this thread. It's super interesting.

I opened [https://github.com/elastic/elasticsearch/issues/19349](https://github.com/elastic/elasticsearch/issues/19349)

BTW, instead of editing your question, it's better to add an answer so anyone will be aware of the fix and we can then mark the answer as solving the problem.

---

<div class="post-metadata">

**Author:** ![martiansnoop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martiansnoop/32/10809_2.png) [@martiansnoop](https://discuss.elastic.co/u/martiansnoop)\
**Post date:** [July 9, 2016, 10:39pm UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/3 "2016-07-09T22:39:44Z")

</div>

> BTW, instead of editing your question, it's better to add an answer so anyone will be aware of the fix and we can then mark the answer as solving the problem.

Good to know! Copied and pasted the answer below in order to mark as solved:

Needed to enable the plugin via the cloud.enabled setting

```auto
new TransportClient
                .Builder()
                .settings(Settings.builder().put("cluster.name", config.clusterName).put("cloud.enabled", true))
                .addPlugin(CloudAwsPlugin.class)
                .build()

```

also needed to set the type of my repo to "s3" instead of "S3". The capital S worked in es 1.7.4, but not in 2.3.3.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 19, 2016, 4:15pm UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/4 "2016-07-19T16:15:14Z")

</div>

So that looks strange. I tried to look at the code today and reproduce the issue you mentioned and was not able.

Here is what I did:

- Launch a node with default settings and cloud-aws plugin.
- Create a TransportClient like this:

```auto
        TransportClient client = new TransportClient.Builder()
                .addPlugin(CloudAwsPlugin.class)
                .build();
        client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));

        PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
                .setType("s3").setSettings(Settings.EMPTY).get();

```

This does not raise the issue you mentioned.  
Also in code we default `cloud.enabled` to `true`. So I can't understand how this happened.

Could you share more details?

---

<div class="post-metadata">

**Author:** ![martiansnoop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martiansnoop/32/10809_2.png) [@martiansnoop](https://discuss.elastic.co/u/martiansnoop)\
**Post date:** [July 23, 2016, 5:20pm UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/5 "2016-07-23T17:20:31Z")

</div>

Thinking about his more, I think the actual error was s3 vs S3. Under 1.7 we had a script to create repos with type "S3" which worked under 1.7, but I think elasticsearch only accepts "s3" as a type now. The cloud.enabled setting was a red herring.

Oh, one other thing re: s3 vs S3, I was wondering if it was intentional behaviour to only accept "s3". It seems like a toLowerCase() on this line could allow both: [https://github.com/elastic/elasticsearch/blob/dea00a0b16f516e6ffb41c4e8a10b24dd992b16e/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java#L375](https://github.com/elastic/elasticsearch/blob/dea00a0b16f516e6ffb41c4e8a10b24dd992b16e/core/src/main/java/org/elasticsearch/repositories/RepositoriesService.java#L375) Alternately it might make sense to call toLowerCase on type in the RepositoryMetaData constructor instead? [https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/cluster/metadata/RepositoryMetaData.java#L44](https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/cluster/metadata/RepositoryMetaData.java#L44)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 25, 2016, 8:38am UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/6 "2016-07-25T08:38:19Z")

</div>

Good to know.

I'm wondering what would happen if you create a repository in an elasticsearch cluster with `S3` as a type in a 1.7 cluster, then upgrade the cluster to 2.3.

Do you think you could test such a scenario?

If it does not work, I'm unsure if the upgrade plugin is able to catch that.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 25, 2016, 8:39am UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/7 "2016-07-25T08:39:25Z")

</div>

Forget my comment as I saw you wrote [S3 snapshot repositories not working after upgrade from 1.7 to 2.3](https://discuss.elastic.co/t/s3-snapshot-repositories-not-working-after-upgrade-from-1-7-to-2-3/56214)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:33pm UTC](https://discuss.elastic.co/t/transportclient-and-creating-an-s3-snapshot-repository/55088/8 "2017-07-05T22:33:14Z")

</div>


