# Unable to use ec2\_vpc\_route\_table to remove route tables.... anyone else?

**URL:** <https://forum.ansible.com/t/unable-to-use-ec2-vpc-route-table-to-remove-route-tables-anyone-else/23194>\
**Category:** Ansible Project\
**Created:** [December 7, 2016, 8:22pm UTC](https://forum.ansible.com/t/unable-to-use-ec2-vpc-route-table-to-remove-route-tables-anyone-else/23194 "2016-12-07T20:22:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rc.loco](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rc.loco](https://forum.ansible.com/u/rc.loco)\
**Post date:** [December 7, 2016, 8:22pm UTC](https://forum.ansible.com/t/unable-to-use-ec2-vpc-route-table-to-remove-route-tables-anyone-else/23194/1 "2016-12-07T20:22:34Z")

</div>

Using version:

ansible 2.2.1.0 (stable-2.2 acad2ba246) last updated 2016/12/07 11:28:43 (GMT -400)  
lib/ansible/modules/core: (detached HEAD 8139278530) last updated 2016/12/07 11:28:55 (GMT -400)  
lib/ansible/modules/extras: (detached HEAD f5f1fc934a) last updated 2016/12/07 11:28:56 (GMT -400)  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides

I’m able to build route tables just fine, but trying to utilize the “state:absent” attribute in the module does not result in removing route tables.

I ended up doing a shell task and calling awscli to handle the removal. I don’t see any specific issues on the extras Github site about this behavior, so I thought I’d inquire here…

Thanks,

–rc

---

<div class="post-metadata">

**Author:** ![igorc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/igorc/32/5491_2.png) [@igorc](https://forum.ansible.com/u/igorc)\
**Post date:** [December 13, 2016, 10:43pm UTC](https://forum.ansible.com/t/unable-to-use-ec2-vpc-route-table-to-remove-route-tables-anyone-else/23194/2 "2016-12-13T22:43:52Z")

</div>

Just to clarify, was the routing table in use by a subnet(s) at that moment? I think AWS will not allow you to remove a resource that is referenced by another one.

---

<div class="post-metadata">

**Author:** ![Rick\_Crelia](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Rick\_Crelia](https://forum.ansible.com/u/Rick_Crelia)\
**Post date:** [December 14, 2016, 1:18pm UTC](https://forum.ansible.com/t/unable-to-use-ec2-vpc-route-table-to-remove-route-tables-anyone-else/23194/3 "2016-12-14T13:18:28Z")

</div>

Not that I could see, since I delete the subnets prior to this step. The only other VPC resource at this point in the play is an Internet Gateway, but if I try to remove it before the route tables, I get an error (because of what you describe, a resource reference).

I haven’t had time to test a simpler version of the role/play (it’s tearing down a VPC with NAT Gateways) to get more info, but I have some now so I’ll tinker on it some more before filing a bug report.

Thanks,

–rc

---

<div class="post-metadata">

**Author:** ![Rick\_Crelia](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Rick\_Crelia](https://forum.ansible.com/u/Rick_Crelia)\
**Post date:** [December 14, 2016, 3:09pm UTC](https://forum.ansible.com/t/unable-to-use-ec2-vpc-route-table-to-remove-route-tables-anyone-else/23194/4 "2016-12-14T15:09:38Z")

</div>

So it turns out that you have to specify the lookup attribute when trying to delete the route table by route\_table\_id. Once I add “lookup: id” to the invocation, the deletion works. This isn’t called out in the module documentation, so I’ll suggest that change to the module docs.

Thanks!

–rc
