I am trying to create a cluster of ElasticSearch
servers on EC2
. ElasticSearch
uses a few defined ports to replicate and perform tasks like leader election. I want to create a security group in my CloudFormation
template that locks down these ports such that only servers in this ElasticSearch
server cluster can communicate with each other.
Is there a simple means by which I can identify a group of servers as a cluster and then assign port access to only those servers?
I may be missing something obvious, but I can't get my CloudFormation
template to build the model I want.
Updated with my existing SG. This complains about circular reference.
ESSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: ES Node SG
VpcId: !FindInMap [ EnvParams, !Ref EnvironmentName, vpc ]
SecurityGroupIngress:
- FromPort: 9200
ToPort: 9200
SourceSecurityGroupId: !Ref ESSecurityGroup
IpProtocol: tcp
- FromPort: 9300
ToPort: 9300
SourceSecurityGroupId: !Ref ESSecurityGroup
IpProtocol: tcp