idempotentcy using ec2_vpc ??

hi all,

been testing out this fun module: 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

"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 :slight_smile:

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

Thanks!

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" :wink: ..

#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

You’ll want to add resource_tags… and read the comments for them in the documentation. :slight_smile:

Nathan

RTFM

my bad