# ec2\_group fails if security group already exists

**URL:** <https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18411>\
**Category:** Ansible Project\
**Created:** [June 5, 2015, 12:50am UTC](https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18411 "2015-06-05T00:50:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gonzalo\_Fernandez](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Gonzalo\_Fernandez](https://forum.ansible.com/u/Gonzalo_Fernandez)\
**Post date:** [June 5, 2015, 12:50am UTC](https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18411/1 "2015-06-05T00:50:52Z")

</div>

Hi

I am having the following problem

If I try to run the following Sec\_Rule it works ok, but if I re-run it it fails  
`

ec2\_security\_groups\_test:

- sg\_name: test-grup  
sg\_description: test-group  
vpc\_id: “vpc-XXXXXX”  
region: “{{ region }}”  
sg\_rules:
- proto: 50  
from\_port: -1  
to\_port: -1  
cidr\_ip: 54.67.116.112/32
- proto: 50  
from\_port: -1  
to\_port: -1  
cidr\_ip: 54.183.92.78/32
- proto: 50  
from\_port: -1  
to\_port: -1  
group\_name: vpn-ap-northeast-1-production  
`

I have tried a number of different options : -1/all… etc… but it always fails

if I use TCP/UDP it seems to work no problem, but I need to define that sort of PROTOCOL…

I am using ansible 1.7.1

Any workaround for this??

Thanks!

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [June 5, 2015, 1:24pm UTC](https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18411/2 "2015-06-05T13:24:53Z")

</div>

added a pr which migh fix this [https://github.com/ansible/ansible-modules-core/pull/1472](https://github.com/ansible/ansible-modules-core/pull/1472) , maybe you can give it a try.

---

<div class="post-metadata">

**Author:** ![Gonzalo\_Fernandez](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Gonzalo\_Fernandez](https://forum.ansible.com/u/Gonzalo_Fernandez)\
**Post date:** [June 5, 2015, 8:27pm UTC](https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18411/3 "2015-06-05T20:27:54Z")

</div>

Hi

This patch seems to have fixed the problem.  
I am working on some more rules topping up and they seem to get through all right.  
So far as I am using protocols 50 and 51 and ALL for all ports it works.

Thanks you so much for helping out on this
