elasticsearch with ec2 needs an EIP
-
20-12-2019 - |
Question
I am trying to setup elasticsearch on 2 ec2 nodes. I have the plugin installed and my config has the following:
cloud:
aws:
access_key: KEY
secret_key: KEY
discovery:
type: ec2
ec2:
groups: security-group
They only discover if I have both this specified and an EIP assigned to each one. Why do I need an EIP assigned? A while ago I had a NAT instance and I did not need the EIP nor the cloud: etc in the config.
Solution
We had some issues with getting nodes within the cluster to see each other in an AWS EC2 setup. We were seeing a timeout issue as well. It turned out that we had added a self-reference to the security group (within the AWS console) in order to get the instances to see each other.
E.g. within the security group settings have the following entry:
TCP Port(Service) Source
0 - 65535 sg-xxxxx (security-group)
Once we added this the discovery worked as expected.
OTHER TIPS
Try use this config
cloud:
aws:
access_key: KEY
secret_key: KEY
discovery:
type: ec2
ec2:
groups: security-group
availability_zones: ap-southeast-1a,ap-southeast-1b
tag:
stage: production
And add Tag "stage" to Instances PS. security-group which security group assign to instances