# ec2\_vpc\_route\_table to delete a given subnet

**URL:** <https://forum.ansible.com/t/ec2-vpc-route-table-to-delete-a-given-subnet/32704>\
**Category:** Ansible Project\
**Created:** [April 16, 2020, 8:32pm UTC](https://forum.ansible.com/t/ec2-vpc-route-table-to-delete-a-given-subnet/32704 "2020-04-16T20:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Sloan](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kyle\_Sloan](https://forum.ansible.com/u/Kyle_Sloan)\
**Post date:** [April 16, 2020, 8:32pm UTC](https://forum.ansible.com/t/ec2-vpc-route-table-to-delete-a-given-subnet/32704/1 "2020-04-16T20:32:55Z")

</div>

Hello all,

I am using the ec2\_vpc\_route\_table module and am able to create the route table, as well as adding more subnets with the “subnets”, “purge\_subnets” and “lookup” parameters. I however have been unable to determine how to remove a subnet from an existing route\_table. The only solution I have found is to query and get all the existing subnets and pass them in with purge\_subnets=true on a second call.

I am hoping I am overlooking, or perhaps missing an example, of how I can do one call that would allow me to delete a given subnet from an existing route\_table.

This works to add,

profile: “{{ aws\_profile }}”  
vpc\_id: “{{ vpc\_id }}”  
state: present  
region: us-east-1

lookup: id

route\_table\_id: rtb-0000000000000

subnets:

- subnet-0418000000000000

purge\_routes: no  
purge\_subnets: no  
purge\_tags: no

I was hoping adding state: absent would work, but that attempts to delete the route\_table instead of the subnet.

Thanks!

[https://docs.ansible.com/ansible/latest/modules/ec2\_vpc\_route\_table\_module.html](https://docs.ansible.com/ansible/latest/modules/ec2_vpc_route_table_module.html)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 16, 2020, 8:57pm UTC](https://forum.ansible.com/t/ec2-vpc-route-table-to-delete-a-given-subnet/32704/2 "2020-04-16T20:57:07Z")

</div>

I think this is how it is supposed to work.  
You define which subnets there should be, and the module will take care of that.  
The only choice is whether to purge subnets that aren't in your desired list.

Dick
