# ec2\_group fails if security group already exists

**URL:** <https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18413>\
**Category:** Ansible Project\
**Created:** [June 5, 2015, 3:21am UTC](https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18413 "2015-06-05T03:21:41Z")\
**Posts on this page:** 1\
**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, 3:21am UTC](https://forum.ansible.com/t/ec2-group-fails-if-security-group-already-exists/18413/1 "2015-06-05T03:21:41Z")

</div>

Hi

I am having the following.  
Given the following Variable rule:

ec2\_security\_groups\_test:

- sg\_name: test-group  
sg\_description: test-group  
vpc\_id: “vpc-XXXXXX”  
region: “{{ region }}”  
sg\_rules:
- proto: 50  
from\_port: -1  
to\_port: -1  
cidr\_ip: 12.12.12.12/32
- proto: 50  
from\_port: -1  
to\_port: -1  
cidr\_ip: 13.13.13.13/32
- proto: 50  
from\_port: -1  
to\_port: -1  
group\_name: test-group

it will work on the 1st run, but on the second I will have:

`InvalidPermission.Duplicate`the specified rule “peer: 12.12.12.12/32, protocol: 50, ALLOW” already existse890595b-9609-4c31-a611-87da7b5de7ae

I have tried specifying Ports, also “-1”… Nothing seems to work.  
If I say TCP or UDP it works fine, but when I specify a numeric port as above I got the issue:

Any possible workaround/tips?

Thanks!
