# ec2\_group with a rule opening a port to other nodes of the same group

**URL:** <https://forum.ansible.com/t/ec2-group-with-a-rule-opening-a-port-to-other-nodes-of-the-same-group/14199>\
**Category:** Ansible Project\
**Created:** [December 21, 2013, 6:49am UTC](https://forum.ansible.com/t/ec2-group-with-a-rule-opening-a-port-to-other-nodes-of-the-same-group/14199 "2013-12-21T06:49:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Verkhovsky](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Alexey\_Verkhovsky](https://forum.ansible.com/u/Alexey_Verkhovsky)\
**Post date:** [December 21, 2013, 6:49am UTC](https://forum.ansible.com/t/ec2-group-with-a-rule-opening-a-port-to-other-nodes-of-the-same-group/14199/1 "2013-12-21T06:49:32Z")

</div>

I need to define an EC2 security group that opens a port to other nodes of the same group. The use case is Elastic Search cluster autodiscovery. Which looks legitimate enough to me 🙂

As far as I can tell, there is no way to do it with the current implementation of ec2\_group module. I could pretty easily write a one-liner patch for that module so that group\_id: self (or some other magic word) makes it so. Is that a good way to do this?

–Alex

---

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [May 16, 2015, 7:05pm UTC](https://forum.ansible.com/t/ec2-group-with-a-rule-opening-a-port-to-other-nodes-of-the-same-group/14199/2 "2015-05-16T19:05:01Z")

</div>

I’ve faced this, with an elasticsearch sg being one of my requirements (in my setup I’d have to make a directed acylic graph of the security groups in order to have them all created in a single run).

Resorted to a playbook with two plays, one that creates my security groups (no rules), tagged create, and another that populates them, tagged configure (or whatever you like).

`

---

<div class="post-metadata">

**Author:** ![Sankalp\_Khare](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sankalp\_Khare](https://forum.ansible.com/u/Sankalp_Khare)\
**Post date:** [May 17, 2015, 9:33am UTC](https://forum.ansible.com/t/ec2-group-with-a-rule-opening-a-port-to-other-nodes-of-the-same-group/14199/3 "2015-05-17T09:33:27Z")

</div>

Just after posting here I found [this post](https://groups.google.com/d/msg/ansible-project/z93RhgUuglg/O8-vr8izhKYJ) in the group. It does what I want. All I need to do is make sure I add group\_desc with group\_name everywhere. And then I can just do a single play, with rules in the calls to ec2\_group.

😃 #happy
