# Struggling to make ec2\_vpc Idempotent

**URL:** <https://forum.ansible.com/t/struggling-to-make-ec2-vpc-idempotent/20396>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 1, 2016, 7:55am UTC](https://forum.ansible.com/t/struggling-to-make-ec2-vpc-idempotent/20396 "2016-02-01T07:55:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Mes](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Ryan\_Mes](https://forum.ansible.com/u/Ryan_Mes)\
**Post date:** [February 1, 2016, 7:55am UTC](https://forum.ansible.com/t/struggling-to-make-ec2-vpc-idempotent/20396/1 "2016-02-01T07:55:07Z")

</div>

> down vote[favorite](http://stackoverflow.com/questions/35125292/cant-figure-out-why-subnet-is-being-updated#)  
>   
>   
> |   
>   
>   
> I am creating a VPC in AWS using Ansible. The following play is run  
>   
>   
>   
> `<br>- name: create vpc with multi-az subnets<br> ec2_vpc:<br> region: "{{ region }}"<br> cidr_block: "{{ vpc_cidr_block }}"<br> resource_tags: '{"Name":"{{ prefix }}_vpc"}'<br> subnets:<br> - cidr: "{{ vpc_cidr_subnet_public_0 }}"<br> az: "{{ region }}{{ availability_zone_0 }}"<br> resource_tags: '{"Name":"{{ prefix }}_subnet_public_0", "Class":"web", "Partner":prefix }'<br> - cidr: "{{ vpc_cidr_subnet_private_0 }}"<br> az: "{{ region }}{{ availability_zone_0 }}"<br> resource_tags: '{"Name":"{{ prefix }}_subnet_private_0", "Class":"db", "Partner":prefix }'<br> - cidr: "{{ vpc_cidr_subnet_private_1 }}"<br> az: "{{ region }}{{ availability_zone_1 }}"<br> resource_tags: '{"Name":"{{ prefix }}_subnet_private_1", "Class":"db", "Partner":prefix }'<br> internet_gateway: yes<br> route_tables:<br> - subnets:<br> - "{{ vpc_cidr_subnet_public_0 }}"<br> routes:<br> - dest: 0.0.0.0/0<br> gw: igw<br> wait: yes<br> register: vpc<br><br>`  
>   
>   
>   
> First time around this creates everything perfectly. Second time around, I expect it to not do anything as everything has been created, however, the public subnet is updated to a private one.  
>   
>   
>   
> Why? What am I doing wrong?  
>   
>   
>   
> Feel free to answer/help with this question here or on stackoverflow - [http://stackoverflow.com/questions/35125292/cant-figure-out-why-subnet-is-being-updated](http://stackoverflow.com/questions/35125292/cant-figure-out-why-subnet-is-being-updated)  
>   
>   
> |

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 2, 2016, 7:12am UTC](https://forum.ansible.com/t/struggling-to-make-ec2-vpc-idempotent/20396/2 "2016-02-02T07:12:29Z")

</div>

can you please check this, I hope it will help you.  
[https://github.com/arbabnazar/ansible-aws-roles/blob/master/roles/vpc/tasks/main.yml#L3](https://github.com/arbabnazar/ansible-aws-roles/blob/master/roles/vpc/tasks/main.yml#L3)
