Updating existing route tables

I have successfully created a VPC B and now I want to peer VPC B and VPC A.

In VPC B I can add the vpc_peering id in route table, but struggling with how to update the route table of VPC A with the vpc_peering id.

Tried using below play:


  • hosts: localhost
    connection: local
    gather_facts: no
    tasks:
  • name: update route table of VPC A
    ec2_vpc_route_table:
    vpc_id: vpc-5becdjn87
    region: us-east-1
    state: present
    propagating_vgw_ids: yes
    tags:
    Name: test-update-rt
    routes:
  • dest: 10.104.0.0/16
    vpc_peering_connection_id: pcx-e67hdo5h

But getting error as:

fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_name”: “ec2_vpc_route_table”}, “module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_dbLJB5/ansible_module_ec2_vpc_route_table.py", line 611, in \n main()\n File "/tmp/ansible_dbLJB5/ansible_module_ec2_vpc_route_table.py", line 599, in main\n result = ensure_route_table_present(connection, module)\n File "/tmp/ansible_dbLJB5/ansible_module_ec2_vpc_route_table.py", line 530, in ensure_route_table_present\n check_mode=module.check_mode)\n File "/tmp/ansible_dbLJB5/ansible_module_ec2_vpc_route_table.py", line 408, in ensure_propagation\n dry_run=check_mode)\n File "/usr/lib/python2.7/dist-packages/boto/vpc/init.py", line 1492, in enable_vgw_route_propagation\n return self.get_status(‘EnableVgwRoutePropagation’, params)\n File "/usr/lib/python2.7/dist-packages/boto/connection.py", line 1227, in get_status\n raise self.ResponseError(response.status, response.reason, body)\nboto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\nGateway.NotAttachedresource true16a7e21a-07ca-4fcc-9678-50fdf3a12ee0\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”, “parsed”: false}

Could anyone please help me on this.