# Ec2 discovery fundamentals

**URL:** <https://discuss.elastic.co/t/ec2-discovery-fundamentals/9659>\
**Category:** Elasticsearch\
**Created:** [November 10, 2012, 7:25pm UTC](https://discuss.elastic.co/t/ec2-discovery-fundamentals/9659 "2012-11-10T19:25:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joec](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@joec](https://discuss.elastic.co/u/joec)\
**Post date:** [November 10, 2012, 7:25pm UTC](https://discuss.elastic.co/t/ec2-discovery-fundamentals/9659/1 "2012-11-10T19:25:27Z")

</div>

Hi, I have a couple fundamental questions about the ec2 discovery mechanism  
that I wasn't clear on.  
Specifically my questions relate to communicating as a client with the java  
api.

If I am using NodeBuilder to auto discover ec2 nodes and connect as a  
client, like so  
settings  
.put("cloud.aws.access\_key", awsCredentials.getAWSAccessKeyId())  
.put("cloud.aws.secret\_key", awsCredentials.getAWSSecretKey())  
.put("cloud.aws.region", "us-east-1")  
.put("discovery.type", "ec2")  
.put("discovery.ec2.host\_type", "public\_ip")  
.put("cloud.aws.region","us-east-1")  
.put("discovery.ec2.group", "mygroup")  
.put("discovery.ec2.tag.esgroup", "mytags");  
node = NodeBuilder.nodeBuilder()  
.clusterName(clusterName)  
.client(true).local(false).data(false)  
.settings(settings.build()).node();  
client = node.client();

does my client's IP/port need to be accessible by the es ec2 nodes it is  
joining?

Second, if I use TransportClient to connect, is there a way to use it along  
with ec2 discovery do find transport addresses, or must I explicitly define  
them ala  
TransportClient tcp = new TransportClient(settings);  
client = tcp.addTransportAddress(new InetSocketTransportAddress(indexHost,indexPort  
));

Thanks,

-Joe

--

---

<div class="post-metadata">

**Author:** ![drewr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewr/32/7803_2.png) [@drewr](https://discuss.elastic.co/u/drewr)\
**Post date:** [November 12, 2012, 3:40am UTC](https://discuss.elastic.co/t/ec2-discovery-fundamentals/9659/2 "2012-11-12T03:40:18Z")

</div>

joe wrote:

> Hi, I have a couple fundamental questions about the ec2 discovery mechanism  
> that I wasn't clear on.

[...]

> does my client's IP/port need to be accessible by the es ec2 nodes  
> it is joining?

Yes. A client node interacts with the cluster just like data nodes,  
but they can't become master and they don't store data.

> Second, if I use TransportClient to connect, is there a way to use it along  
> with ec2 discovery do find transport addresses, or must I explicitly define  
> them ala  
> TransportClient tcp = new TransportClient(settings);  
> client = tcp.addTransportAddress(new InetSocketTransportAddress(indexHost,indexPort  
> ));

Normally you would need a node to seed your discovery, but with ec2  
this may be possible. I haven't tried to run a discovery service  
without a running node though. Those classes are dependent upon many  
services expected to be available.

However, you can probably reuse some of the cloud plugin code in  
AwsEc2UnicastHostsProvider to do some manual discovery before calling  
addTransportAddress().

-Drew

--

---

<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 6, 2017, 3:04am UTC](https://discuss.elastic.co/t/ec2-discovery-fundamentals/9659/3 "2017-07-06T03:04:53Z")

</div>


