ec2_vpc_route_table update?

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}