# idempotentcy using ec2\_vpc ??

**URL:** <https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414>\
**Category:** Ansible Project\
**Created:** [June 5, 2014, 7:39pm UTC](https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414 "2014-06-05T19:39:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregory\_Spranger](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@Gregory\_Spranger](https://forum.ansible.com/u/Gregory_Spranger)\
**Post date:** [June 5, 2014, 7:39pm UTC](https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414/1 "2014-06-05T19:39:50Z")

</div>

hi all,

been testing out this fun module: [http://docs.ansible.com/ec2\_vpc\_module.html](http://docs.ansible.com/ec2_vpc_module.html)

curious if anyone has figured out a way to have “idempotency” when creating a VPC using this module … more specifically, our subnets and route tables do change, so i would prefer that after i update the play – it would update the existing VPC and not create a new one … below is my example code:

`  
local\_action:  
module: ec2\_vpc  
aws\_access\_key: yoyoma  
aws\_secret\_key: mamayo  
state: present  
cidr\_block: 10.169.0.0/16  
region: us-east-1  
subnets:

- cidr: 10.169.1.0/24  
az: us-east-1b
- cidr: 10.169.2.0/24  
az: us-east-1b
- cidr: 10.169.3.0/24  
az: us-east-1b  
internet\_gateway: True  
route\_tables:
- subnets:
- 10.169.1.0/24  
routes:
- dest: 0.0.0.0/0  
gw: igw  
register: vpc  
`

thanks !!  
greg

---

<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:** [June 6, 2014, 12:43pm UTC](https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414/2 "2014-06-06T12:43:56Z")

</div>

"curious if anyone has figured out a way to have “idempotency” when creating a VPC using this module "

Idempotency is one of my least favorite words, because it’s used in so many different ways by different people to mean many different things 🙂

Just to be sure, what is the above code block doing that you don’t like?

Thanks!

---

<div class="post-metadata">

**Author:** ![Gregory\_K\_Spranger](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@Gregory\_K\_Spranger](https://forum.ansible.com/u/Gregory_K_Spranger)\
**Post date:** [June 6, 2014, 1:06pm UTC](https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414/3 "2014-06-06T13:06:17Z")

</div>

yeah -- i re-read what i wrote and cringed a little -- sorry about  
that .. let me explain better what i am hoping for ..

#1 in my example play, it creates a VPC just fine .. problem is, if i  
run it again -- with no changes to the code -- it will create a new  
VPC with the same options .. i guess i am hoping it would not do that  
(\<\< my definition of "idempotency" 😉 ..

#2 let's say i update example code with new subnet, i would \*hope\*  
that it would update the existing VPC instead of creating a new one --  
as it does now ..

mind you, my tests were pretty basic and i did not implement the use  
of resource\_tags or define a vpc\_id (\<\< which i ASSumed is only for  
deleting a VPC)

thanks,  
greg

---

<div class="post-metadata">

**Author:** ![Nathan\_Howell](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@Nathan\_Howell](https://forum.ansible.com/u/Nathan_Howell)\
**Post date:** [June 6, 2014, 6:04pm UTC](https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414/4 "2014-06-06T18:04:21Z")

</div>

You’ll want to add resource\_tags… and read the comments for them in the documentation. 🙂

Nathan

---

<div class="post-metadata">

**Author:** ![Gregory\_K\_Spranger](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@Gregory\_K\_Spranger](https://forum.ansible.com/u/Gregory_K_Spranger)\
**Post date:** [June 6, 2014, 6:11pm UTC](https://forum.ansible.com/t/idempotentcy-using-ec2-vpc/15414/5 "2014-06-06T18:11:34Z")

</div>

RTFM

my bad
