# Add egress rules in ec2\_group

**URL:** <https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14494>\
**Category:** Ansible Developer\
**Created:** [February 5, 2014, 3:06pm UTC](https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14494 "2014-02-05T15:06:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Codezerk](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@Codezerk](https://forum.ansible.com/u/Codezerk)\
**Post date:** [February 5, 2014, 3:06pm UTC](https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14494/1 "2014-02-05T15:06:19Z")

</div>

I’m not sure why this option didn’t exist to begin with but I certainly use it all the time.  
I have the necessary changes over at [https://github.com/codezerk/ansible](https://github.com/codezerk/ansible)  
One thing to note here is that it will remove the default egress rule if not defined in the rules list, similar to the ingress rules.

example:

- name: example ec2 group  
local\_action:  
module: ec2\_group  
name: example  
description: an example EC2 group  
vpc\_id: 12345  
region: eu-west-1a  
ec2\_secret\_key: SECRET  
ec2\_access\_key: ACCESS  
rules:
- proto: tcp  
from\_port: 80  
to\_port: 80  
cidr\_ip: [0.0.0.0/0](http://0.0.0.0/0)  
egress: yes \<------------------ this will mark it as egress
- proto: tcp  
from\_port: 22  
to\_port: 22  
cidr\_ip: [10.0.0.0/8](http://10.0.0.0/8)
- proto: udp  
from\_port: 10050  
to\_port: 10050  
cidr\_ip: [10.0.0.0/8](http://10.0.0.0/8)
- proto: udp  
from\_port: 10051  
to\_port: 10051  
group\_id: sg-12345678
- proto: all

# the containing group name may be specified here

group\_name: example

---

<div class="post-metadata">

**Author:** ![Alexander\_Popov](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@Alexander\_Popov](https://forum.ansible.com/u/Alexander_Popov)\
**Post date:** [February 20, 2014, 9:55pm UTC](https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14494/2 "2014-02-20T21:55:17Z")

</div>

+1

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 21, 2014, 1:09am UTC](https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14494/3 "2014-02-21T01:09:04Z")

</div>

Yep, please submit a pull request for this.

Thanks!
