# ec2\_vpc\_route\_table update?

**URL:** <https://forum.ansible.com/t/ec2-vpc-route-table-update/20536>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [February 11, 2016, 11:12am UTC](https://forum.ansible.com/t/ec2-vpc-route-table-update/20536 "2016-02-11T11:12:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Graham](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@Matthew\_Graham](https://forum.ansible.com/u/Matthew_Graham)\
**Post date:** [February 11, 2016, 11:12am UTC](https://forum.ansible.com/t/ec2-vpc-route-table-update/20536/1 "2016-02-11T11:12:18Z")

</div>

Hi All

Using the ec2\_vpc\_route\_table module to create a route table. It works but if I terminate the NAT’s that are referenced in item.instance, it leaves the lovely “black hole” in the Route table in AWS. When I run the playbook again, it does not update the route table with the new instance id from the newly spun up NAT. If I go in to AWS and manually do it, its fine. I can then run the playbook and its fine (as the instance has been now added by me manually). Have I missed something? If I actually go into AWS and delete the routes and let the playbook re-create them, its fine.

- name: Web Private Route Tables  
ec2\_vpc\_route\_table:  
vpc\_id: “{{ vpc\_id }}”  
tags:  
Name: “{{ env | default(‘test’) }}_web\_private_{{ item.az }}”  
state: present  
region: “{{ aws\_region }}”  
subnets: “{{ item.subnet }}”  
routes:
- dest: 0.0.0.0/0  
instance\_id: “{{ item.instance }}”
- dest: 10.88.0.0/16  
instance\_id: “{{ item.instance }}”

with\_items:

- { Name: natA, subnet: “{{ cidr }}.3.0/24”, instance: “{{ nat\_servers.results[0].tagged\_instances[0].id }}”, az: a }
- { Name: natB, subnet: “{{ cidr }}.4.0/24”, instance: “{{ nat\_servers.results[1].tagged\_instances[0].id }}”, az: b }

Error:

TASK [Web Private Route Tables] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: argument of type ‘NoneType’ is not iterable  
failed: [localhost] =\> (item={u’subnet’: u’10.40.3.0/24’, u’az’: u’a’, u’Name’: u’natA’, u’instance’: u’i-ee193e31’}) =\> {“failed”: true, “item”: {“Name”: “natA”, “az”: “a”, “instance”: “i-ee193e31”, “subnet”: “10.40.3.0/24”}, “parsed”: false}
