# Add egress rules in ec2\_group

**URL:** <https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14493>\
**Category:** Ansible Project\
**Created:** [February 5, 2014, 10:29am UTC](https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14493 "2014-02-05T10:29:07Z")\
**Posts on this page:** 1\
**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, 10:29am UTC](https://forum.ansible.com/t/add-egress-rules-in-ec2-group/14493/1 "2014-02-05T10:29:07Z")

</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 [GitHub - codezerk/ansible: Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.](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  
egress: yes \<------------------ this will mark it as egress
- proto: tcp  
from\_port: 22  
to\_port: 22  
cidr\_ip: 10.0.0.0/8
- proto: udp  
from\_port: 10050  
to\_port: 10050  
cidr\_ip: 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
